aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Runtime
diff options
context:
space:
mode:
authorlbsa712008-06-24 21:09:49 +0000
committerlbsa712008-06-24 21:09:49 +0000
commit6b7930104bdb845d3b9c085dc04f52b6446f23b1 (patch)
tree05ee45781a455817fa400bb99f30f4d19d4eb1f8 /OpenSim/Region/ScriptEngine/Shared/Api/Runtime
parentbased on positive feedback on performance of making keys fixed length (diff)
downloadopensim-SC-6b7930104bdb845d3b9c085dc04f52b6446f23b1.zip
opensim-SC-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.gz
opensim-SC-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.bz2
opensim-SC-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.xz
* Applied patch from Melanie, mantis issue #1581 - "Refactor LSL language, api and compiler out of XEngine"
"First stage in a major Script Engine refactor, that will result in the LSL implementaions ebing reconverged. Not there yet, but one major part is done." Thank you, Melanie!
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Runtime')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs421
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs1732
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs199
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj161
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build62
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp43
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs124
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs218
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs234
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs103
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs188
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs111
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs154
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs133
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs288
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs156
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs4457
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs71
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs62
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs196
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs1644
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs5651
23 files changed, 16420 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
new file mode 100644
index 0000000..69be69b
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -0,0 +1,421 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
30using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
31
32namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
33{
34 public partial class ScriptBaseClass : MarshalByRefObject
35 {
36 // LSL CONSTANTS
37 public const int TRUE = 1;
38 public const int FALSE = 0;
39
40 public const int STATUS_PHYSICS = 1;
41 public const int STATUS_ROTATE_X = 2;
42 public const int STATUS_ROTATE_Y = 4;
43 public const int STATUS_ROTATE_Z = 8;
44 public const int STATUS_PHANTOM = 16;
45 public const int STATUS_SANDBOX = 32;
46 public const int STATUS_BLOCK_GRAB = 64;
47 public const int STATUS_DIE_AT_EDGE = 128;
48 public const int STATUS_RETURN_AT_EDGE = 256;
49 public const int STATUS_CAST_SHADOWS = 512;
50
51 public const int AGENT = 1;
52 public const int ACTIVE = 2;
53 public const int PASSIVE = 4;
54 public const int SCRIPTED = 8;
55
56 public const int CONTROL_FWD = 1;
57 public const int CONTROL_BACK = 2;
58 public const int CONTROL_LEFT = 4;
59 public const int CONTROL_RIGHT = 8;
60 public const int CONTROL_UP = 16;
61 public const int CONTROL_DOWN = 32;
62 public const int CONTROL_ROT_LEFT = 256;
63 public const int CONTROL_ROT_RIGHT = 512;
64 public const int CONTROL_LBUTTON = 268435456;
65 public const int CONTROL_ML_LBUTTON = 1073741824;
66
67 //Permissions
68 public const int PERMISSION_DEBIT = 2;
69 public const int PERMISSION_TAKE_CONTROLS = 4;
70 public const int PERMISSION_REMAP_CONTROLS = 8;
71 public const int PERMISSION_TRIGGER_ANIMATION = 16;
72 public const int PERMISSION_ATTACH = 32;
73 public const int PERMISSION_RELEASE_OWNERSHIP = 64;
74 public const int PERMISSION_CHANGE_LINKS = 128;
75 public const int PERMISSION_CHANGE_JOINTS = 256;
76 public const int PERMISSION_CHANGE_PERMISSIONS = 512;
77 public const int PERMISSION_TRACK_CAMERA = 1024;
78
79 public const int AGENT_FLYING = 1;
80 public const int AGENT_ATTACHMENTS = 2;
81 public const int AGENT_SCRIPTED = 4;
82 public const int AGENT_MOUSELOOK = 8;
83 public const int AGENT_SITTING = 16;
84 public const int AGENT_ON_OBJECT = 32;
85 public const int AGENT_AWAY = 64;
86 public const int AGENT_WALKING = 128;
87 public const int AGENT_IN_AIR = 256;
88 public const int AGENT_TYPING = 512;
89 public const int AGENT_CROUCHING = 1024;
90 public const int AGENT_BUSY = 2048;
91 public const int AGENT_ALWAYS_RUN = 4096;
92
93 //Particle Systems
94 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
95 public const int PSYS_PART_INTERP_SCALE_MASK = 2;
96 public const int PSYS_PART_BOUNCE_MASK = 4;
97 public const int PSYS_PART_WIND_MASK = 8;
98 public const int PSYS_PART_FOLLOW_SRC_MASK = 16;
99 public const int PSYS_PART_FOLLOW_VELOCITY_MASK = 32;
100 public const int PSYS_PART_TARGET_POS_MASK = 64;
101 public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
102 public const int PSYS_PART_EMISSIVE_MASK = 256;
103 public const int PSYS_PART_FLAGS = 0;
104 public const int PSYS_PART_START_COLOR = 1;
105 public const int PSYS_PART_START_ALPHA = 2;
106 public const int PSYS_PART_END_COLOR = 3;
107 public const int PSYS_PART_END_ALPHA = 4;
108 public const int PSYS_PART_START_SCALE = 5;
109 public const int PSYS_PART_END_SCALE = 6;
110 public const int PSYS_PART_MAX_AGE = 7;
111 public const int PSYS_SRC_ACCEL = 8;
112 public const int PSYS_SRC_PATTERN = 9;
113 public const int PSYS_SRC_INNERANGLE = 10;
114 public const int PSYS_SRC_OUTERANGLE = 11;
115 public const int PSYS_SRC_TEXTURE = 12;
116 public const int PSYS_SRC_BURST_RATE = 13;
117 public const int PSYS_SRC_BURST_PART_COUNT = 15;
118 public const int PSYS_SRC_BURST_RADIUS = 16;
119 public const int PSYS_SRC_BURST_SPEED_MIN = 17;
120 public const int PSYS_SRC_BURST_SPEED_MAX = 18;
121 public const int PSYS_SRC_MAX_AGE = 19;
122 public const int PSYS_SRC_TARGET_KEY = 20;
123 public const int PSYS_SRC_OMEGA = 21;
124 public const int PSYS_SRC_ANGLE_BEGIN = 22;
125 public const int PSYS_SRC_ANGLE_END = 23;
126 public const int PSYS_SRC_PATTERN_DROP = 1;
127 public const int PSYS_SRC_PATTERN_EXPLODE = 2;
128 public const int PSYS_SRC_PATTERN_ANGLE = 4;
129 public const int PSYS_SRC_PATTERN_ANGLE_CONE = 8;
130 public const int PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16;
131
132 public const int VEHICLE_TYPE_NONE = 0;
133 public const int VEHICLE_TYPE_SLED = 1;
134 public const int VEHICLE_TYPE_CAR = 2;
135 public const int VEHICLE_TYPE_BOAT = 3;
136 public const int VEHICLE_TYPE_AIRPLANE = 4;
137 public const int VEHICLE_TYPE_BALLOON = 5;
138 public const int VEHICLE_LINEAR_FRICTION_TIMESCALE = 16;
139 public const int VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17;
140 public const int VEHICLE_LINEAR_MOTOR_DIRECTION = 18;
141 public const int VEHICLE_LINEAR_MOTOR_OFFSET = 20;
142 public const int VEHICLE_ANGULAR_MOTOR_DIRECTION = 19;
143 public const int VEHICLE_HOVER_HEIGHT = 24;
144 public const int VEHICLE_HOVER_EFFICIENCY = 25;
145 public const int VEHICLE_HOVER_TIMESCALE = 26;
146 public const int VEHICLE_BUOYANCY = 27;
147 public const int VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28;
148 public const int VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29;
149 public const int VEHICLE_LINEAR_MOTOR_TIMESCALE = 30;
150 public const int VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31;
151 public const int VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32;
152 public const int VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33;
153 public const int VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34;
154 public const int VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35;
155 public const int VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36;
156 public const int VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37;
157 public const int VEHICLE_BANKING_EFFICIENCY = 38;
158 public const int VEHICLE_BANKING_MIX = 39;
159 public const int VEHICLE_BANKING_TIMESCALE = 40;
160 public const int VEHICLE_REFERENCE_FRAME = 44;
161 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
162 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
163 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
164 public const int VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 8;
165 public const int VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 16;
166 public const int VEHICLE_FLAG_HOVER_UP_ONLY = 32;
167 public const int VEHICLE_FLAG_LIMIT_MOTOR_UP = 64;
168 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
169 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
170 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
171
172 public const int INVENTORY_ALL = -1;
173 public const int INVENTORY_NONE = -1;
174 public const int INVENTORY_TEXTURE = 0;
175 public const int INVENTORY_SOUND = 1;
176 public const int INVENTORY_LANDMARK = 3;
177 public const int INVENTORY_CLOTHING = 5;
178 public const int INVENTORY_OBJECT = 6;
179 public const int INVENTORY_NOTECARD = 7;
180 public const int INVENTORY_SCRIPT = 10;
181 public const int INVENTORY_BODYPART = 13;
182 public const int INVENTORY_ANIMATION = 20;
183 public const int INVENTORY_GESTURE = 21;
184
185 public const int ATTACH_CHEST = 1;
186 public const int ATTACH_HEAD = 2;
187 public const int ATTACH_LSHOULDER = 3;
188 public const int ATTACH_RSHOULDER = 4;
189 public const int ATTACH_LHAND = 5;
190 public const int ATTACH_RHAND = 6;
191 public const int ATTACH_LFOOT = 7;
192 public const int ATTACH_RFOOT = 8;
193 public const int ATTACH_BACK = 9;
194 public const int ATTACH_PELVIS = 10;
195 public const int ATTACH_MOUTH = 11;
196 public const int ATTACH_CHIN = 12;
197 public const int ATTACH_LEAR = 13;
198 public const int ATTACH_REAR = 14;
199 public const int ATTACH_LEYE = 15;
200 public const int ATTACH_REYE = 16;
201 public const int ATTACH_NOSE = 17;
202 public const int ATTACH_RUARM = 18;
203 public const int ATTACH_RLARM = 19;
204 public const int ATTACH_LUARM = 20;
205 public const int ATTACH_LLARM = 21;
206 public const int ATTACH_RHIP = 22;
207 public const int ATTACH_RULEG = 23;
208 public const int ATTACH_RLLEG = 24;
209 public const int ATTACH_LHIP = 25;
210 public const int ATTACH_LULEG = 26;
211 public const int ATTACH_LLLEG = 27;
212 public const int ATTACH_BELLY = 28;
213 public const int ATTACH_RPEC = 29;
214 public const int ATTACH_LPEC = 30;
215
216 public const int LAND_LEVEL = 0;
217 public const int LAND_RAISE = 1;
218 public const int LAND_LOWER = 2;
219 public const int LAND_SMOOTH = 3;
220 public const int LAND_NOISE = 4;
221 public const int LAND_REVERT = 5;
222 public const int LAND_SMALL_BRUSH = 1;
223 public const int LAND_MEDIUM_BRUSH = 2;
224 public const int LAND_LARGE_BRUSH = 3;
225
226 //Agent Dataserver
227 public const int DATA_ONLINE = 1;
228 public const int DATA_NAME = 2;
229 public const int DATA_BORN = 3;
230 public const int DATA_RATING = 4;
231 public const int DATA_SIM_POS = 5;
232 public const int DATA_SIM_STATUS = 6;
233 public const int DATA_SIM_RATING = 7;
234 public const int DATA_PAYINFO = 8;
235
236 public const int ANIM_ON = 1;
237 public const int LOOP = 2;
238 public const int REVERSE = 4;
239 public const int PING_PONG = 8;
240 public const int SMOOTH = 16;
241 public const int ROTATE = 32;
242 public const int SCALE = 64;
243 public const int ALL_SIDES = -1;
244 public const int LINK_SET = -1;
245 public const int LINK_ROOT = 1;
246 public const int LINK_ALL_OTHERS = -2;
247 public const int LINK_ALL_CHILDREN = -3;
248 public const int LINK_THIS = -4;
249 public const int CHANGED_INVENTORY = 1;
250 public const int CHANGED_COLOR = 2;
251 public const int CHANGED_SHAPE = 4;
252 public const int CHANGED_SCALE = 8;
253 public const int CHANGED_TEXTURE = 16;
254 public const int CHANGED_LINK = 32;
255 public const int CHANGED_ALLOWED_DROP = 64;
256 public const int CHANGED_OWNER = 128;
257 public const int CHANGED_REGION_RESTART = 256;
258 public const int TYPE_INVALID = 0;
259 public const int TYPE_INTEGER = 1;
260 public const int TYPE_double = 2;
261 public const int TYPE_STRING = 3;
262 public const int TYPE_KEY = 4;
263 public const int TYPE_VECTOR = 5;
264 public const int TYPE_ROTATION = 6;
265
266 //XML RPC Remote Data Channel
267 public const int REMOTE_DATA_CHANNEL = 1;
268 public const int REMOTE_DATA_REQUEST = 2;
269 public const int REMOTE_DATA_REPLY = 3;
270
271 //llHTTPRequest
272 public const int HTTP_METHOD = 0;
273 public const int HTTP_MIMETYPE = 1;
274 public const int HTTP_BODY_MAXLENGTH = 2;
275 public const int HTTP_VERIFY_CERT = 3;
276
277 public const int PRIM_MATERIAL = 2;
278 public const int PRIM_PHYSICS = 3;
279 public const int PRIM_TEMP_ON_REZ = 4;
280 public const int PRIM_PHANTOM = 5;
281 public const int PRIM_POSITION = 6;
282 public const int PRIM_SIZE = 7;
283 public const int PRIM_ROTATION = 8;
284 public const int PRIM_TYPE = 9;
285 public const int PRIM_TEXTURE = 17;
286 public const int PRIM_COLOR = 18;
287 public const int PRIM_BUMP_SHINY = 19;
288 public const int PRIM_FULLBRIGHT = 20;
289 public const int PRIM_FLEXIBLE = 21;
290 public const int PRIM_TEXGEN = 22;
291 public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
292 public const int PRIM_POINT_LIGHT = 23; // Huh?
293 public const int PRIM_TEXGEN_DEFAULT = 0;
294 public const int PRIM_TEXGEN_PLANAR = 1;
295
296 public const int PRIM_TYPE_BOX = 0;
297 public const int PRIM_TYPE_CYLINDER = 1;
298 public const int PRIM_TYPE_PRISM = 2;
299 public const int PRIM_TYPE_SPHERE = 3;
300 public const int PRIM_TYPE_TORUS = 4;
301 public const int PRIM_TYPE_TUBE = 5;
302 public const int PRIM_TYPE_RING = 6;
303 public const int PRIM_TYPE_SCULPT = 7;
304
305 public const int PRIM_HOLE_DEFAULT = 0;
306 public const int PRIM_HOLE_CIRCLE = 16;
307 public const int PRIM_HOLE_SQUARE = 32;
308 public const int PRIM_HOLE_TRIANGLE = 48;
309
310 public const int PRIM_MATERIAL_STONE = 0;
311 public const int PRIM_MATERIAL_METAL = 1;
312 public const int PRIM_MATERIAL_GLASS = 2;
313 public const int PRIM_MATERIAL_WOOD = 3;
314 public const int PRIM_MATERIAL_FLESH = 4;
315 public const int PRIM_MATERIAL_PLASTIC = 5;
316 public const int PRIM_MATERIAL_RUBBER = 6;
317 public const int PRIM_MATERIAL_LIGHT = 7;
318
319 public const int PRIM_SHINY_NONE = 0;
320 public const int PRIM_SHINY_LOW = 1;
321 public const int PRIM_SHINY_MEDIUM = 2;
322 public const int PRIM_SHINY_HIGH = 3;
323 public const int PRIM_BUMP_NONE = 0;
324 public const int PRIM_BUMP_BRIGHT = 1;
325 public const int PRIM_BUMP_DARK = 2;
326 public const int PRIM_BUMP_WOOD = 3;
327 public const int PRIM_BUMP_BARK = 4;
328 public const int PRIM_BUMP_BRICKS = 5;
329 public const int PRIM_BUMP_CHECKER = 6;
330 public const int PRIM_BUMP_CONCRETE = 7;
331 public const int PRIM_BUMP_TILE = 8;
332 public const int PRIM_BUMP_STONE = 9;
333 public const int PRIM_BUMP_DISKS = 10;
334 public const int PRIM_BUMP_GRAVEL = 11;
335 public const int PRIM_BUMP_BLOBS = 12;
336 public const int PRIM_BUMP_SIDING = 13;
337 public const int PRIM_BUMP_LARGETILE = 14;
338 public const int PRIM_BUMP_STUCCO = 15;
339 public const int PRIM_BUMP_SUCTION = 16;
340 public const int PRIM_BUMP_WEAVE = 17;
341
342 public const int PRIM_SCULPT_TYPE_SPHERE = 1;
343 public const int PRIM_SCULPT_TYPE_TORUS = 2;
344 public const int PRIM_SCULPT_TYPE_PLANE = 3;
345 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
346
347 public const int MASK_BASE = 0;
348 public const int MASK_OWNER = 1;
349 public const int MASK_GROUP = 2;
350 public const int MASK_EVERYONE = 3;
351 public const int MASK_NEXT = 4;
352
353 public const int PERM_TRANSFER = 8192;
354 public const int PERM_MODIFY = 16384;
355 public const int PERM_COPY = 32768;
356 public const int PERM_MOVE = 524288;
357 public const int PERM_ALL = 2147483647;
358
359 public const int PARCEL_MEDIA_COMMAND_STOP = 0;
360 public const int PARCEL_MEDIA_COMMAND_PAUSE = 1;
361 public const int PARCEL_MEDIA_COMMAND_PLAY = 2;
362 public const int PARCEL_MEDIA_COMMAND_LOOP = 3;
363 public const int PARCEL_MEDIA_COMMAND_TEXTURE = 4;
364 public const int PARCEL_MEDIA_COMMAND_URL = 5;
365 public const int PARCEL_MEDIA_COMMAND_TIME = 6;
366 public const int PARCEL_MEDIA_COMMAND_AGENT = 7;
367 public const int PARCEL_MEDIA_COMMAND_UNLOAD = 8;
368 public const int PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
369
370 public const int PAY_HIDE = -1;
371 public const int PAY_DEFAULT = -2;
372
373 public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
374 public const string EOF = "\n\n\n";
375 public const double PI = 3.14159274f;
376 public const double TWO_PI = 6.28318548f;
377 public const double PI_BY_TWO = 1.57079637f;
378 public const double DEG_TO_RAD = 0.01745329238f;
379 public const double RAD_TO_DEG = 57.29578f;
380 public const double SQRT2 = 1.414213538f;
381 public const int STRING_TRIM_HEAD = 1;
382 public const int STRING_TRIM_TAIL = 2;
383 public const int STRING_TRIM = 3;
384 public const int LIST_STAT_RANGE = 0;
385 public const int LIST_STAT_MIN = 1;
386 public const int LIST_STAT_MAX = 2;
387 public const int LIST_STAT_MEAN = 3;
388 public const int LIST_STAT_MEDIAN = 4;
389 public const int LIST_STAT_STD_DEV = 5;
390 public const int LIST_STAT_SUM = 6;
391 public const int LIST_STAT_SUM_SQUARES = 7;
392 public const int LIST_STAT_NUM_COUNT = 8;
393 public const int LIST_STAT_GEOMETRIC_MEAN = 9;
394 public const int LIST_STAT_HARMONIC_MEAN = 100;
395
396 //ParcelPrim Categories
397 public const int PARCEL_COUNT_TOTAL = 0;
398 public const int PARCEL_COUNT_OWNER = 1;
399 public const int PARCEL_COUNT_GROUP = 2;
400 public const int PARCEL_COUNT_OTHER = 3;
401 public const int PARCEL_COUNT_SELECTED = 4;
402 public const int PARCEL_COUNT_TEMP = 5;
403
404 public const int DEBUG_CHANNEL = 0x7FFFFFFF;
405 public const int PUBLIC_CHANNEL = 0x00000000;
406
407 public const int OBJECT_NAME = 1;
408 public const int OBJECT_DESC = 2;
409 public const int OBJECT_POS = 3;
410 public const int OBJECT_ROT = 4;
411 public const int OBJECT_VELOCITY = 5;
412 public const int OBJECT_OWNER = 6;
413 public const int OBJECT_GROUP = 7;
414 public const int OBJECT_CREATOR = 8;
415
416 // Can not be public const?
417 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
418 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
419
420 }
421}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
new file mode 100644
index 0000000..7b3907f
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -0,0 +1,1732 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.ScriptEngine.Interfaces;
35using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
36using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
37using key = System.String;
38using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
39using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
40
41namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
42{
43 public partial class ScriptBaseClass : MarshalByRefObject
44 {
45 public ILSL_Api m_LSL_Functions;
46
47 public void ApiTypeLSL(IScriptApi api)
48 {
49 if(!(api is ILSL_Api))
50 return;
51
52 m_LSL_Functions = (ILSL_Api)api;
53 }
54
55 public void state(string newState)
56 {
57 m_LSL_Functions.state(newState);
58 }
59
60 //
61 // Script functions
62 //
63 public void llSay(int channelID, string text)
64 {
65 m_LSL_Functions.llSay(channelID, text);
66 }
67
68 public double llSin(double f)
69 {
70 return m_LSL_Functions.llSin(f);
71 }
72
73 public double llCos(double f)
74 {
75 return m_LSL_Functions.llCos(f);
76 }
77
78 public double llTan(double f)
79 {
80 return m_LSL_Functions.llTan(f);
81 }
82
83 public double llAtan2(double x, double y)
84 {
85 return m_LSL_Functions.llAtan2(x, y);
86 }
87
88 public double llSqrt(double f)
89 {
90 return m_LSL_Functions.llSqrt(f);
91 }
92
93 public double llPow(double fbase, double fexponent)
94 {
95 return m_LSL_Functions.llPow(fbase, fexponent);
96 }
97
98 public LSL_Types.LSLInteger llAbs(int i)
99 {
100 return m_LSL_Functions.llAbs(i);
101 }
102
103 public double llFabs(double f)
104 {
105 return m_LSL_Functions.llFabs(f);
106 }
107
108 public double llFrand(double mag)
109 {
110 return m_LSL_Functions.llFrand(mag);
111 }
112
113 public LSL_Types.LSLInteger llFloor(double f)
114 {
115 return m_LSL_Functions.llFloor(f);
116 }
117
118 public LSL_Types.LSLInteger llCeil(double f)
119 {
120 return m_LSL_Functions.llCeil(f);
121 }
122
123 public LSL_Types.LSLInteger llRound(double f)
124 {
125 return m_LSL_Functions.llRound(f);
126 }
127
128 public double llVecMag(vector v)
129 {
130 return m_LSL_Functions.llVecMag(v);
131 }
132
133 public vector llVecNorm(vector v)
134 {
135 return m_LSL_Functions.llVecNorm(v);
136 }
137
138 public double llVecDist(vector a, vector b)
139 {
140 return m_LSL_Functions.llVecDist(a, b);
141 }
142
143 public vector llRot2Euler(rotation r)
144 {
145 return m_LSL_Functions.llRot2Euler(r);
146 }
147
148 public rotation llEuler2Rot(vector v)
149 {
150 return m_LSL_Functions.llEuler2Rot(v);
151 }
152
153 public rotation llAxes2Rot(vector fwd, vector left, vector up)
154 {
155 return m_LSL_Functions.llAxes2Rot(fwd, left, up);
156 }
157
158 public vector llRot2Fwd(rotation r)
159 {
160 return m_LSL_Functions.llRot2Fwd(r);
161 }
162
163 public vector llRot2Left(rotation r)
164 {
165 return m_LSL_Functions.llRot2Left(r);
166 }
167
168 public vector llRot2Up(rotation r)
169 {
170 return m_LSL_Functions.llRot2Up(r);
171 }
172
173 public rotation llRotBetween(vector start, vector end)
174 {
175 return m_LSL_Functions.llRotBetween(start, end);
176 }
177
178 public void llWhisper(int channelID, string text)
179 {
180 m_LSL_Functions.llWhisper(channelID, text);
181 }
182
183 public void llShout(int channelID, string text)
184 {
185 m_LSL_Functions.llShout(channelID, text);
186 }
187
188 public void llRegionSay(int channelID, string text)
189 {
190 m_LSL_Functions.llRegionSay(channelID, text);
191 }
192
193 public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg)
194 {
195 return m_LSL_Functions.llListen(channelID, name, ID, msg);
196 }
197
198 public void llListenControl(int number, int active)
199 {
200 m_LSL_Functions.llListenControl(number, active);
201 }
202
203 public void llListenRemove(int number)
204 {
205 m_LSL_Functions.llListenRemove(number);
206 }
207
208 public void llSensor(string name, string id, int type, double range, double arc)
209 {
210 m_LSL_Functions.llSensor(name, id, type, range, arc);
211 }
212
213 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
214 {
215 m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate);
216 }
217
218 public void llSensorRemove()
219 {
220 m_LSL_Functions.llSensorRemove();
221 }
222
223 public string llDetectedName(int number)
224 {
225 return m_LSL_Functions.llDetectedName(number);
226 }
227
228 public string llDetectedKey(int number)
229 {
230 return m_LSL_Functions.llDetectedKey(number);
231 }
232
233 public string llDetectedOwner(int number)
234 {
235 return m_LSL_Functions.llDetectedOwner(number);
236 }
237
238 public LSL_Types.LSLInteger llDetectedType(int number)
239 {
240 return m_LSL_Functions.llDetectedType(number);
241 }
242
243 public vector llDetectedPos(int number)
244 {
245 return m_LSL_Functions.llDetectedPos(number);
246 }
247
248 public vector llDetectedVel(int number)
249 {
250 return m_LSL_Functions.llDetectedVel(number);
251 }
252
253 public vector llDetectedGrab(int number)
254 {
255 return m_LSL_Functions.llDetectedGrab(number);
256 }
257
258 public rotation llDetectedRot(int number)
259 {
260 return m_LSL_Functions.llDetectedRot(number);
261 }
262
263 public LSL_Types.LSLInteger llDetectedGroup(int number)
264 {
265 return m_LSL_Functions.llDetectedGroup(number);
266 }
267
268 public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
269 {
270 return m_LSL_Functions.llDetectedLinkNumber(number);
271 }
272
273 public void llDie()
274 {
275 m_LSL_Functions.llDie();
276 }
277
278 public double llGround(vector offset)
279 {
280 return m_LSL_Functions.llGround(offset);
281 }
282
283 public double llCloud(vector offset)
284 {
285 return m_LSL_Functions.llCloud(offset);
286 }
287
288 public vector llWind(vector offset)
289 {
290 return m_LSL_Functions.llWind(offset);
291 }
292
293 public void llSetStatus(int status, int value)
294 {
295 m_LSL_Functions.llSetStatus(status, value);
296 }
297
298 public LSL_Types.LSLInteger llGetStatus(int status)
299 {
300 return m_LSL_Functions.llGetStatus(status);
301 }
302
303 public void llSetScale(vector scale)
304 {
305 m_LSL_Functions.llSetScale(scale);
306 }
307
308 public vector llGetScale()
309 {
310 return m_LSL_Functions.llGetScale();
311 }
312
313 public void llSetColor(vector color, int face)
314 {
315 m_LSL_Functions.llSetColor(color, face);
316 }
317
318 public double llGetAlpha(int face)
319 {
320 return m_LSL_Functions.llGetAlpha(face);
321 }
322
323 public void llSetAlpha(double alpha, int face)
324 {
325 m_LSL_Functions.llSetAlpha(alpha, face);
326 }
327
328 public vector llGetColor(int face)
329 {
330 return m_LSL_Functions.llGetColor(face);
331 }
332
333 public void llSetTexture(string texture, int face)
334 {
335 m_LSL_Functions.llSetTexture(texture, face);
336 }
337
338 public void llScaleTexture(double u, double v, int face)
339 {
340 m_LSL_Functions.llScaleTexture(u, v, face);
341 }
342
343 public void llOffsetTexture(double u, double v, int face)
344 {
345 m_LSL_Functions.llOffsetTexture(u, v, face);
346 }
347
348 public void llRotateTexture(double rotation, int face)
349 {
350 m_LSL_Functions.llRotateTexture(rotation, face);
351 }
352
353 public string llGetTexture(int face)
354 {
355 return m_LSL_Functions.llGetTexture(face);
356 }
357
358 public void llSetPos(vector pos)
359 {
360 m_LSL_Functions.llSetPos(pos);
361 }
362
363 public vector llGetPos()
364 {
365 return m_LSL_Functions.llGetPos();
366 }
367
368 public vector llGetLocalPos()
369 {
370 return m_LSL_Functions.llGetLocalPos();
371 }
372
373 public void llSetRot(rotation rot)
374 {
375 m_LSL_Functions.llSetRot(rot);
376 }
377
378 public rotation llGetRot()
379 {
380 return m_LSL_Functions.llGetRot();
381 }
382
383 public rotation llGetLocalRot()
384 {
385 return m_LSL_Functions.llGetLocalRot();
386 }
387
388 public void llSetForce(vector force, int local)
389 {
390 m_LSL_Functions.llSetForce(force, local);
391 }
392
393 public vector llGetForce()
394 {
395 return m_LSL_Functions.llGetForce();
396 }
397
398 public LSL_Types.LSLInteger llTarget(vector position, double range)
399 {
400 return m_LSL_Functions.llTarget(position, range);
401 }
402
403 public void llTargetRemove(int number)
404 {
405 m_LSL_Functions.llTargetRemove(number);
406 }
407
408 public LSL_Types.LSLInteger llRotTarget(rotation rot, double error)
409 {
410 return m_LSL_Functions.llRotTarget(rot, error);
411 }
412
413 public void llRotTargetRemove(int number)
414 {
415 m_LSL_Functions.llRotTargetRemove(number);
416 }
417
418 public void llMoveToTarget(vector target, double tau)
419 {
420 m_LSL_Functions.llMoveToTarget(target, tau);
421 }
422
423 public void llStopMoveToTarget()
424 {
425 m_LSL_Functions.llStopMoveToTarget();
426 }
427
428 public void llApplyImpulse(vector force, int local)
429 {
430 m_LSL_Functions.llApplyImpulse(force, local);
431 }
432
433 public void llApplyRotationalImpulse(vector force, int local)
434 {
435 m_LSL_Functions.llApplyRotationalImpulse(force, local);
436 }
437
438 public void llSetTorque(vector torque, int local)
439 {
440 m_LSL_Functions.llSetTorque(torque, local);
441 }
442
443 public vector llGetTorque()
444 {
445 return m_LSL_Functions.llGetTorque();
446 }
447
448 public void llSetForceAndTorque(vector force, vector torque, int local)
449 {
450 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
451 }
452
453 public vector llGetVel()
454 {
455 return m_LSL_Functions.llGetVel();
456 }
457
458 public vector llGetAccel()
459 {
460 return m_LSL_Functions.llGetAccel();
461 }
462
463 public vector llGetOmega()
464 {
465 return m_LSL_Functions.llGetOmega();
466 }
467
468 public double llGetTimeOfDay()
469 {
470 return m_LSL_Functions.llGetTimeOfDay();
471 }
472
473 public double llGetWallclock()
474 {
475 return m_LSL_Functions.llGetWallclock();
476 }
477
478 public double llGetTime()
479 {
480 return m_LSL_Functions.llGetTime();
481 }
482
483 public void llResetTime()
484 {
485 m_LSL_Functions.llResetTime();
486 }
487
488 public double llGetAndResetTime()
489 {
490 return m_LSL_Functions.llGetAndResetTime();
491 }
492
493 public void llSound()
494 {
495 m_LSL_Functions.llSound();
496 }
497
498 public void llPlaySound(string sound, double volume)
499 {
500 m_LSL_Functions.llPlaySound(sound, volume);
501 }
502
503 public void llLoopSound(string sound, double volume)
504 {
505 m_LSL_Functions.llLoopSound(sound, volume);
506 }
507
508 public void llLoopSoundMaster(string sound, double volume)
509 {
510 m_LSL_Functions.llLoopSoundMaster(sound, volume);
511 }
512
513 public void llLoopSoundSlave(string sound, double volume)
514 {
515 m_LSL_Functions.llLoopSoundSlave(sound, volume);
516 }
517
518 public void llPlaySoundSlave(string sound, double volume)
519 {
520 m_LSL_Functions.llPlaySoundSlave(sound, volume);
521 }
522
523 public void llTriggerSound(string sound, double volume)
524 {
525 m_LSL_Functions.llTriggerSound(sound, volume);
526 }
527
528 public void llStopSound()
529 {
530 m_LSL_Functions.llStopSound();
531 }
532
533 public void llPreloadSound(string sound)
534 {
535 m_LSL_Functions.llPreloadSound(sound);
536 }
537
538 public string llGetSubString(string src, int start, int end)
539 {
540 return m_LSL_Functions.llGetSubString(src, start, end);
541 }
542
543 public string llDeleteSubString(string src, int start, int end)
544 {
545 return m_LSL_Functions.llDeleteSubString(src, start, end);
546 }
547
548 public string llInsertString(string dst, int position, string src)
549 {
550 return m_LSL_Functions.llInsertString(dst, position, src);
551 }
552
553 public string llToUpper(string source)
554 {
555 return m_LSL_Functions.llToUpper(source);
556 }
557
558 public string llToLower(string source)
559 {
560 return m_LSL_Functions.llToLower(source);
561 }
562
563 public LSL_Types.LSLInteger llGiveMoney(string destination, int amount)
564 {
565 return m_LSL_Functions.llGiveMoney(destination, amount);
566 }
567
568 public void llMakeExplosion()
569 {
570 m_LSL_Functions.llMakeExplosion();
571 }
572
573 public void llMakeFountain()
574 {
575 m_LSL_Functions.llMakeFountain();
576 }
577
578 public void llMakeSmoke()
579 {
580 m_LSL_Functions.llMakeSmoke();
581 }
582
583 public void llMakeFire()
584 {
585 m_LSL_Functions.llMakeFire();
586 }
587
588 public void llRezObject(string inventory, vector pos, vector vel, rotation rot, int param)
589 {
590 m_LSL_Functions.llRezObject(inventory, pos, vel, rot, param);
591 }
592
593 public void llLookAt(vector target, double strength, double damping)
594 {
595 m_LSL_Functions.llLookAt(target, strength, damping);
596 }
597
598 public void llStopLookAt()
599 {
600 m_LSL_Functions.llStopLookAt();
601 }
602
603 public void llSetTimerEvent(double sec)
604 {
605 m_LSL_Functions.llSetTimerEvent(sec);
606 }
607
608 public void llSleep(double sec)
609 {
610 m_LSL_Functions.llSleep(sec);
611 }
612
613 public double llGetMass()
614 {
615 return m_LSL_Functions.llGetMass();
616 }
617
618 public void llCollisionFilter(string name, string id, int accept)
619 {
620 m_LSL_Functions.llCollisionFilter(name, id, accept);
621 }
622
623 public void llTakeControls(int controls, int accept, int pass_on)
624 {
625 m_LSL_Functions.llTakeControls(controls, accept, pass_on);
626 }
627
628 public void llReleaseControls()
629 {
630 m_LSL_Functions.llReleaseControls();
631 }
632
633 public void llAttachToAvatar(int attachment)
634 {
635 m_LSL_Functions.llAttachToAvatar(attachment);
636 }
637
638 public void llDetachFromAvatar()
639 {
640 m_LSL_Functions.llDetachFromAvatar();
641 }
642
643 public void llTakeCamera()
644 {
645 m_LSL_Functions.llTakeCamera();
646 }
647
648 public void llReleaseCamera()
649 {
650 m_LSL_Functions.llReleaseCamera();
651 }
652
653 public string llGetOwner()
654 {
655 return m_LSL_Functions.llGetOwner();
656 }
657
658 public void llInstantMessage(string user, string message)
659 {
660 m_LSL_Functions.llInstantMessage(user, message);
661 }
662
663 public void llEmail(string address, string subject, string message)
664 {
665 m_LSL_Functions.llEmail(address, subject, message);
666 }
667
668 public void llGetNextEmail(string address, string subject)
669 {
670 m_LSL_Functions.llGetNextEmail(address, subject);
671 }
672
673 public string llGetKey()
674 {
675 return m_LSL_Functions.llGetKey();
676 }
677
678 public void llSetBuoyancy(double buoyancy)
679 {
680 m_LSL_Functions.llSetBuoyancy(buoyancy);
681 }
682
683 public void llSetHoverHeight(double height, int water, double tau)
684 {
685 m_LSL_Functions.llSetHoverHeight(height, water, tau);
686 }
687
688 public void llStopHover()
689 {
690 m_LSL_Functions.llStopHover();
691 }
692
693 public void llMinEventDelay(double delay)
694 {
695 m_LSL_Functions.llMinEventDelay(delay);
696 }
697
698 public void llSoundPreload()
699 {
700 m_LSL_Functions.llSoundPreload();
701 }
702
703 public void llRotLookAt(rotation target, double strength, double damping)
704 {
705 m_LSL_Functions.llRotLookAt(target, strength, damping);
706 }
707
708 public LSL_Types.LSLInteger llStringLength(string str)
709 {
710 return m_LSL_Functions.llStringLength(str);
711 }
712
713 public void llStartAnimation(string anim)
714 {
715 m_LSL_Functions.llStartAnimation(anim);
716 }
717
718 public void llStopAnimation(string anim)
719 {
720 m_LSL_Functions.llStopAnimation(anim);
721 }
722
723 public void llPointAt()
724 {
725 m_LSL_Functions.llPointAt();
726 }
727
728 public void llStopPointAt()
729 {
730 m_LSL_Functions.llStopPointAt();
731 }
732
733 public void llTargetOmega(vector axis, double spinrate, double gain)
734 {
735 m_LSL_Functions.llTargetOmega(axis, spinrate, gain);
736 }
737
738 public LSL_Types.LSLInteger llGetStartParameter()
739 {
740 return m_LSL_Functions.llGetStartParameter();
741 }
742
743 public void llGodLikeRezObject(string inventory, vector pos)
744 {
745 m_LSL_Functions.llGodLikeRezObject(inventory, pos);
746 }
747
748 public void llRequestPermissions(string agent, int perm)
749 {
750 m_LSL_Functions.llRequestPermissions(agent, perm);
751 }
752
753 public string llGetPermissionsKey()
754 {
755 return m_LSL_Functions.llGetPermissionsKey();
756 }
757
758 public LSL_Types.LSLInteger llGetPermissions()
759 {
760 return m_LSL_Functions.llGetPermissions();
761 }
762
763 public LSL_Types.LSLInteger llGetLinkNumber()
764 {
765 return m_LSL_Functions.llGetLinkNumber();
766 }
767
768 public void llSetLinkColor(int linknumber, vector color, int face)
769 {
770 m_LSL_Functions.llSetLinkColor(linknumber, color, face);
771 }
772
773 public void llCreateLink(string target, int parent)
774 {
775 m_LSL_Functions.llCreateLink(target, parent);
776 }
777
778 public void llBreakLink(int linknum)
779 {
780 m_LSL_Functions.llBreakLink(linknum);
781 }
782
783 public void llBreakAllLinks()
784 {
785 m_LSL_Functions.llBreakAllLinks();
786 }
787
788 public string llGetLinkKey(int linknum)
789 {
790 return m_LSL_Functions.llGetLinkKey(linknum);
791 }
792
793 public string llGetLinkName(int linknum)
794 {
795 return m_LSL_Functions.llGetLinkName(linknum);
796 }
797
798 public LSL_Types.LSLInteger llGetInventoryNumber(int type)
799 {
800 return m_LSL_Functions.llGetInventoryNumber(type);
801 }
802
803 public string llGetInventoryName(int type, int number)
804 {
805 return m_LSL_Functions.llGetInventoryName(type, number);
806 }
807
808 public void llSetScriptState(string name, int run)
809 {
810 m_LSL_Functions.llSetScriptState(name, run);
811 }
812
813 public double llGetEnergy()
814 {
815 return m_LSL_Functions.llGetEnergy();
816 }
817
818 public void llGiveInventory(string destination, string inventory)
819 {
820 m_LSL_Functions.llGiveInventory(destination, inventory);
821 }
822
823 public void llRemoveInventory(string item)
824 {
825 m_LSL_Functions.llRemoveInventory(item);
826 }
827
828 public void llSetText(string text, vector color, double alpha)
829 {
830 m_LSL_Functions.llSetText(text, color, alpha);
831 }
832
833 public double llWater(vector offset)
834 {
835 return m_LSL_Functions.llWater(offset);
836 }
837
838 public void llPassTouches(int pass)
839 {
840 m_LSL_Functions.llPassTouches(pass);
841 }
842
843 public string llRequestAgentData(string id, int data)
844 {
845 return m_LSL_Functions.llRequestAgentData(id, data);
846 }
847
848 public string llRequestInventoryData(string name)
849 {
850 return m_LSL_Functions.llRequestInventoryData(name);
851 }
852
853 public void llSetDamage(double damage)
854 {
855 m_LSL_Functions.llSetDamage(damage);
856 }
857
858 public void llTeleportAgentHome(string agent)
859 {
860 m_LSL_Functions.llTeleportAgentHome(agent);
861 }
862
863 public void llModifyLand(int action, int brush)
864 {
865 m_LSL_Functions.llModifyLand(action, brush);
866 }
867
868 public void llCollisionSound(string impact_sound, double impact_volume)
869 {
870 m_LSL_Functions.llCollisionSound(impact_sound, impact_volume);
871 }
872
873 public void llCollisionSprite(string impact_sprite)
874 {
875 m_LSL_Functions.llCollisionSprite(impact_sprite);
876 }
877
878 public string llGetAnimation(string id)
879 {
880 return m_LSL_Functions.llGetAnimation(id);
881 }
882
883 public void llResetScript()
884 {
885 m_LSL_Functions.llResetScript();
886 }
887
888 public void llMessageLinked(int linknum, int num, string str, string id)
889 {
890 m_LSL_Functions.llMessageLinked(linknum, num, str, id);
891 }
892
893 public void llPushObject(string target, vector impulse, vector ang_impulse, int local)
894 {
895 m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local);
896 }
897
898 public void llPassCollisions(int pass)
899 {
900 m_LSL_Functions.llPassCollisions(pass);
901 }
902
903 public string llGetScriptName()
904 {
905 return m_LSL_Functions.llGetScriptName();
906 }
907
908 public LSL_Types.LSLInteger llGetNumberOfSides()
909 {
910 return m_LSL_Functions.llGetNumberOfSides();
911 }
912
913 public rotation llAxisAngle2Rot(vector axis, double angle)
914 {
915 return m_LSL_Functions.llAxisAngle2Rot(axis, angle);
916 }
917
918 public vector llRot2Axis(rotation rot)
919 {
920 return m_LSL_Functions.llRot2Axis(rot);
921 }
922
923 public double llRot2Angle(rotation rot)
924 {
925 return m_LSL_Functions.llRot2Angle(rot);
926 }
927
928 public double llAcos(double val)
929 {
930 return m_LSL_Functions.llAcos(val);
931 }
932
933 public double llAsin(double val)
934 {
935 return m_LSL_Functions.llAsin(val);
936 }
937
938 public double llAngleBetween(rotation a, rotation b)
939 {
940 return m_LSL_Functions.llAngleBetween(a, b);
941 }
942
943 public string llGetInventoryKey(string name)
944 {
945 return m_LSL_Functions.llGetInventoryKey(name);
946 }
947
948 public void llAllowInventoryDrop(int add)
949 {
950 m_LSL_Functions.llAllowInventoryDrop(add);
951 }
952
953 public vector llGetSunDirection()
954 {
955 return m_LSL_Functions.llGetSunDirection();
956 }
957
958 public vector llGetTextureOffset(int face)
959 {
960 return m_LSL_Functions.llGetTextureOffset(face);
961 }
962
963 public vector llGetTextureScale(int side)
964 {
965 return m_LSL_Functions.llGetTextureScale(side);
966 }
967
968 public double llGetTextureRot(int side)
969 {
970 return m_LSL_Functions.llGetTextureRot(side);
971 }
972
973 public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern)
974 {
975 return m_LSL_Functions.llSubStringIndex(source, pattern);
976 }
977
978 public string llGetOwnerKey(string id)
979 {
980 return m_LSL_Functions.llGetOwnerKey(id);
981 }
982
983 public vector llGetCenterOfMass()
984 {
985 return m_LSL_Functions.llGetCenterOfMass();
986 }
987
988 public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
989 {
990 return m_LSL_Functions.llListSort(src, stride, ascending);
991 }
992
993 public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src)
994 {
995 return m_LSL_Functions.llGetListLength(src);
996 }
997
998 public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index)
999 {
1000 return m_LSL_Functions.llList2Integer(src, index);
1001 }
1002
1003 public string llList2String(LSL_Types.list src, int index)
1004 {
1005 return m_LSL_Functions.llList2String(src, index);
1006 }
1007
1008 public string llList2Key(LSL_Types.list src, int index)
1009 {
1010 return m_LSL_Functions.llList2Key(src, index);
1011 }
1012
1013 public vector llList2Vector(LSL_Types.list src, int index)
1014 {
1015 return m_LSL_Functions.llList2Vector(src, index);
1016 }
1017
1018 public rotation llList2Rot(LSL_Types.list src, int index)
1019 {
1020 return m_LSL_Functions.llList2Rot(src, index);
1021 }
1022
1023 public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
1024 {
1025 return m_LSL_Functions.llList2List(src, start, end);
1026 }
1027
1028 public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
1029 {
1030 return m_LSL_Functions.llDeleteSubList(src, start, end);
1031 }
1032
1033 public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index)
1034 {
1035 return m_LSL_Functions.llGetListEntryType(src, index);
1036 }
1037
1038 public string llList2CSV(LSL_Types.list src)
1039 {
1040 return m_LSL_Functions.llList2CSV(src);
1041 }
1042
1043 public LSL_Types.list llCSV2List(string src)
1044 {
1045 return m_LSL_Functions.llCSV2List(src);
1046 }
1047
1048 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
1049 {
1050 return m_LSL_Functions.llListRandomize(src, stride);
1051 }
1052
1053 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
1054 {
1055 return m_LSL_Functions.llList2ListStrided(src, start, end, stride);
1056 }
1057
1058 public vector llGetRegionCorner()
1059 {
1060 return m_LSL_Functions.llGetRegionCorner();
1061 }
1062
1063 public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start)
1064 {
1065 return m_LSL_Functions.llListInsertList(dest, src, start);
1066 }
1067
1068 public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test)
1069 {
1070 return m_LSL_Functions.llListFindList(src, test);
1071 }
1072
1073 public string llGetObjectName()
1074 {
1075 return m_LSL_Functions.llGetObjectName();
1076 }
1077
1078 public void llSetObjectName(string name)
1079 {
1080 m_LSL_Functions.llSetObjectName(name);
1081 }
1082
1083 public string llGetDate()
1084 {
1085 return m_LSL_Functions.llGetDate();
1086 }
1087
1088 public LSL_Types.LSLInteger llEdgeOfWorld(vector pos, vector dir)
1089 {
1090 return m_LSL_Functions.llEdgeOfWorld(pos, dir);
1091 }
1092
1093 public LSL_Types.LSLInteger llGetAgentInfo(string id)
1094 {
1095 return m_LSL_Functions.llGetAgentInfo(id);
1096 }
1097
1098 public void llAdjustSoundVolume(double volume)
1099 {
1100 m_LSL_Functions.llAdjustSoundVolume(volume);
1101 }
1102
1103 public void llSetSoundQueueing(int queue)
1104 {
1105 m_LSL_Functions.llSetSoundQueueing(queue);
1106 }
1107
1108 public void llSetSoundRadius(double radius)
1109 {
1110 m_LSL_Functions.llSetSoundRadius(radius);
1111 }
1112
1113 public string llKey2Name(string id)
1114 {
1115 return m_LSL_Functions.llKey2Name(id);
1116 }
1117
1118 public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
1119 {
1120 m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate);
1121 }
1122
1123 public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west)
1124 {
1125 m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west);
1126 }
1127
1128 public void llEjectFromLand(string pest)
1129 {
1130 m_LSL_Functions.llEjectFromLand(pest);
1131 }
1132
1133 public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
1134 {
1135 return m_LSL_Functions.llParseString2List(str,separators,spacers);
1136 }
1137
1138 public LSL_Types.LSLInteger llOverMyLand(string id)
1139 {
1140 return m_LSL_Functions.llOverMyLand(id);
1141 }
1142
1143 public string llGetLandOwnerAt(vector pos)
1144 {
1145 return m_LSL_Functions.llGetLandOwnerAt(pos);
1146 }
1147
1148 public string llGetNotecardLine(string name, int line)
1149 {
1150 return m_LSL_Functions.llGetNotecardLine(name, line);
1151 }
1152
1153 public vector llGetAgentSize(string id)
1154 {
1155 return m_LSL_Functions.llGetAgentSize(id);
1156 }
1157
1158 public LSL_Types.LSLInteger llSameGroup(string agent)
1159 {
1160 return m_LSL_Functions.llSameGroup(agent);
1161 }
1162
1163 public void llUnSit(string id)
1164 {
1165 m_LSL_Functions.llUnSit(id);
1166 }
1167
1168 public vector llGroundSlope(vector offset)
1169 {
1170 return m_LSL_Functions.llGroundSlope(offset);
1171 }
1172
1173 public vector llGroundNormal(vector offset)
1174 {
1175 return m_LSL_Functions.llGroundNormal(offset);
1176 }
1177
1178 public vector llGroundContour(vector offset)
1179 {
1180 return m_LSL_Functions.llGroundContour(offset);
1181 }
1182
1183 public LSL_Types.LSLInteger llGetAttached()
1184 {
1185 return m_LSL_Functions.llGetAttached();
1186 }
1187
1188 public LSL_Types.LSLInteger llGetFreeMemory()
1189 {
1190 return m_LSL_Functions.llGetFreeMemory();
1191 }
1192
1193 public string llGetRegionName()
1194 {
1195 return m_LSL_Functions.llGetRegionName();
1196 }
1197
1198 public double llGetRegionTimeDilation()
1199 {
1200 return m_LSL_Functions.llGetRegionTimeDilation();
1201 }
1202
1203 public double llGetRegionFPS()
1204 {
1205 return m_LSL_Functions.llGetRegionFPS();
1206 }
1207
1208 public void llParticleSystem(LSL_Types.list rules)
1209 {
1210 m_LSL_Functions.llParticleSystem(rules);
1211 }
1212
1213 public void llGroundRepel(double height, int water, double tau)
1214 {
1215 m_LSL_Functions.llGroundRepel(height, water, tau);
1216 }
1217
1218 public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory)
1219 {
1220 m_LSL_Functions.llGiveInventoryList(destination, category, inventory);
1221 }
1222
1223 public void llSetVehicleType(int type)
1224 {
1225 m_LSL_Functions.llSetVehicleType(type);
1226 }
1227
1228 public void llSetVehicledoubleParam(int param, double value)
1229 {
1230 m_LSL_Functions.llSetVehicledoubleParam(param, value);
1231 }
1232
1233 public void llSetVehicleFloatParam(int param, float value)
1234 {
1235 m_LSL_Functions.llSetVehicleFloatParam(param, value);
1236 }
1237
1238 public void llSetVehicleVectorParam(int param, vector vec)
1239 {
1240 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1241 }
1242
1243 public void llSetVehicleRotationParam(int param, rotation rot)
1244 {
1245 m_LSL_Functions.llSetVehicleRotationParam(param, rot);
1246 }
1247
1248 public void llSetVehicleFlags(int flags)
1249 {
1250 m_LSL_Functions.llSetVehicleFlags(flags);
1251 }
1252
1253 public void llRemoveVehicleFlags(int flags)
1254 {
1255 m_LSL_Functions.llRemoveVehicleFlags(flags);
1256 }
1257
1258 public void llSitTarget(vector offset, rotation rot)
1259 {
1260 m_LSL_Functions.llSitTarget(offset, rot);
1261 }
1262
1263 public string llAvatarOnSitTarget()
1264 {
1265 return m_LSL_Functions.llAvatarOnSitTarget();
1266 }
1267
1268 public void llAddToLandPassList(string avatar, double hours)
1269 {
1270 m_LSL_Functions.llAddToLandPassList(avatar, hours);
1271 }
1272
1273 public void llSetTouchText(string text)
1274 {
1275 m_LSL_Functions.llSetTouchText(text);
1276 }
1277
1278 public void llSetSitText(string text)
1279 {
1280 m_LSL_Functions.llSetSitText(text);
1281 }
1282
1283 public void llSetCameraEyeOffset(vector offset)
1284 {
1285 m_LSL_Functions.llSetCameraEyeOffset(offset);
1286 }
1287
1288 public void llSetCameraAtOffset(vector offset)
1289 {
1290 m_LSL_Functions.llSetCameraAtOffset(offset);
1291 }
1292
1293 public string llDumpList2String(LSL_Types.list src, string seperator)
1294 {
1295 return m_LSL_Functions.llDumpList2String(src, seperator);
1296 }
1297
1298 public LSL_Types.LSLInteger llScriptDanger(vector pos)
1299 {
1300 return m_LSL_Functions.llScriptDanger(pos);
1301 }
1302
1303 public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
1304 {
1305 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
1306 }
1307
1308 public void llVolumeDetect(int detect)
1309 {
1310 m_LSL_Functions.llVolumeDetect(detect);
1311 }
1312
1313 public void llResetOtherScript(string name)
1314 {
1315 m_LSL_Functions.llResetOtherScript(name);
1316 }
1317
1318 public LSL_Types.LSLInteger llGetScriptState(string name)
1319 {
1320 return m_LSL_Functions.llGetScriptState(name);
1321 }
1322
1323 public void llRemoteLoadScript()
1324 {
1325 m_LSL_Functions.llRemoteLoadScript();
1326 }
1327
1328 public void llSetRemoteScriptAccessPin(int pin)
1329 {
1330 m_LSL_Functions.llSetRemoteScriptAccessPin(pin);
1331 }
1332
1333 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
1334 {
1335 m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param);
1336 }
1337
1338 public void llOpenRemoteDataChannel()
1339 {
1340 m_LSL_Functions.llOpenRemoteDataChannel();
1341 }
1342
1343 public string llSendRemoteData(string channel, string dest, int idata, string sdata)
1344 {
1345 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
1346 }
1347
1348 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
1349 {
1350 m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata);
1351 }
1352
1353 public void llCloseRemoteDataChannel(string channel)
1354 {
1355 m_LSL_Functions.llCloseRemoteDataChannel(channel);
1356 }
1357
1358 public string llMD5String(string src, int nonce)
1359 {
1360 return m_LSL_Functions.llMD5String(src, nonce);
1361 }
1362
1363 public void llSetPrimitiveParams(LSL_Types.list rules)
1364 {
1365 m_LSL_Functions.llSetPrimitiveParams(rules);
1366 }
1367
1368 public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules)
1369 {
1370 m_LSL_Functions.llSetLinkPrimitiveParams(linknumber, rules);
1371 }
1372 public string llStringToBase64(string str)
1373 {
1374 return m_LSL_Functions.llStringToBase64(str);
1375 }
1376
1377 public string llBase64ToString(string str)
1378 {
1379 return m_LSL_Functions.llBase64ToString(str);
1380 }
1381
1382 public void llXorBase64Strings()
1383 {
1384 m_LSL_Functions.llXorBase64Strings();
1385 }
1386
1387 public void llRemoteDataSetRegion()
1388 {
1389 m_LSL_Functions.llRemoteDataSetRegion();
1390 }
1391
1392 public double llLog10(double val)
1393 {
1394 return m_LSL_Functions.llLog10(val);
1395 }
1396
1397 public double llLog(double val)
1398 {
1399 return m_LSL_Functions.llLog(val);
1400 }
1401
1402 public LSL_Types.list llGetAnimationList(string id)
1403 {
1404 return m_LSL_Functions.llGetAnimationList(id);
1405 }
1406
1407 public void llSetParcelMusicURL(string url)
1408 {
1409 m_LSL_Functions.llSetParcelMusicURL(url);
1410 }
1411
1412 public vector llGetRootPosition()
1413 {
1414 return m_LSL_Functions.llGetRootPosition();
1415 }
1416
1417 public rotation llGetRootRotation()
1418 {
1419 return m_LSL_Functions.llGetRootRotation();
1420 }
1421
1422 public string llGetObjectDesc()
1423 {
1424 return m_LSL_Functions.llGetObjectDesc();
1425 }
1426
1427 public void llSetObjectDesc(string desc)
1428 {
1429 m_LSL_Functions.llSetObjectDesc(desc);
1430 }
1431
1432 public string llGetCreator()
1433 {
1434 return m_LSL_Functions.llGetCreator();
1435 }
1436
1437 public string llGetTimestamp()
1438 {
1439 return m_LSL_Functions.llGetTimestamp();
1440 }
1441
1442 public void llSetLinkAlpha(int linknumber, double alpha, int face)
1443 {
1444 m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face);
1445 }
1446
1447 public LSL_Types.LSLInteger llGetNumberOfPrims()
1448 {
1449 return m_LSL_Functions.llGetNumberOfPrims();
1450 }
1451
1452 public string llGetNumberOfNotecardLines(string name)
1453 {
1454 return m_LSL_Functions.llGetNumberOfNotecardLines(name);
1455 }
1456
1457 public LSL_Types.list llGetBoundingBox(string obj)
1458 {
1459 return m_LSL_Functions.llGetBoundingBox(obj);
1460 }
1461
1462 public vector llGetGeometricCenter()
1463 {
1464 return m_LSL_Functions.llGetGeometricCenter();
1465 }
1466
1467 public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules)
1468 {
1469 return m_LSL_Functions.llGetPrimitiveParams(rules);
1470 }
1471
1472 public string llIntegerToBase64(int number)
1473 {
1474 return m_LSL_Functions.llIntegerToBase64(number);
1475 }
1476
1477 public LSL_Types.LSLInteger llBase64ToInteger(string str)
1478 {
1479 return m_LSL_Functions.llBase64ToInteger(str);
1480 }
1481
1482 public double llGetGMTclock()
1483 {
1484 return m_LSL_Functions.llGetGMTclock();
1485 }
1486
1487 public string llGetSimulatorHostname()
1488 {
1489 return m_LSL_Functions.llGetSimulatorHostname();
1490 }
1491
1492 public void llSetLocalRot(rotation rot)
1493 {
1494 m_LSL_Functions.llSetLocalRot(rot);
1495 }
1496
1497 public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers)
1498 {
1499 return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers);
1500 }
1501
1502 public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param)
1503 {
1504 m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param);
1505 }
1506
1507 public LSL_Types.LSLInteger llGetObjectPermMask(int mask)
1508 {
1509 return m_LSL_Functions.llGetObjectPermMask(mask);
1510 }
1511
1512 public void llSetObjectPermMask(int mask, int value)
1513 {
1514 m_LSL_Functions.llSetObjectPermMask(mask, value);
1515 }
1516
1517 public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask)
1518 {
1519 return m_LSL_Functions.llGetInventoryPermMask(item, mask);
1520 }
1521
1522 public void llSetInventoryPermMask(string item, int mask, int value)
1523 {
1524 m_LSL_Functions.llSetInventoryPermMask(item, mask, value);
1525 }
1526
1527 public string llGetInventoryCreator(string item)
1528 {
1529 return m_LSL_Functions.llGetInventoryCreator(item);
1530 }
1531
1532 public void llOwnerSay(string msg)
1533 {
1534 m_LSL_Functions.llOwnerSay(msg);
1535 }
1536
1537 public string llRequestSimulatorData(string simulator, int data)
1538 {
1539 return m_LSL_Functions.llRequestSimulatorData(simulator, data);
1540 }
1541
1542 public void llForceMouselook(int mouselook)
1543 {
1544 m_LSL_Functions.llForceMouselook(mouselook);
1545 }
1546
1547 public double llGetObjectMass(string id)
1548 {
1549 return m_LSL_Functions.llGetObjectMass(id);
1550 }
1551
1552 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
1553 {
1554 return m_LSL_Functions.llListReplaceList(dest, src, start, end);
1555 }
1556
1557 public void llLoadURL(string avatar_id, string message, string url)
1558 {
1559 m_LSL_Functions.llLoadURL(avatar_id, message, url);
1560 }
1561
1562 public void llParcelMediaCommandList(LSL_Types.list commandList)
1563 {
1564 m_LSL_Functions.llParcelMediaCommandList(commandList);
1565 }
1566
1567 public void llParcelMediaQuery()
1568 {
1569 m_LSL_Functions.llParcelMediaQuery();
1570 }
1571
1572 public LSL_Types.LSLInteger llModPow(int a, int b, int c)
1573 {
1574 return m_LSL_Functions.llModPow(a, b, c);
1575 }
1576
1577 public LSL_Types.LSLInteger llGetInventoryType(string name)
1578 {
1579 return m_LSL_Functions.llGetInventoryType(name);
1580 }
1581
1582 public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
1583 {
1584 m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons);
1585 }
1586
1587 public vector llGetCameraPos()
1588 {
1589 return m_LSL_Functions.llGetCameraPos();
1590 }
1591
1592 public rotation llGetCameraRot()
1593 {
1594 return m_LSL_Functions.llGetCameraRot();
1595 }
1596
1597 public void llSetPrimURL()
1598 {
1599 m_LSL_Functions.llSetPrimURL();
1600 }
1601
1602 public void llRefreshPrimURL()
1603 {
1604 m_LSL_Functions.llRefreshPrimURL();
1605 }
1606
1607 public string llEscapeURL(string url)
1608 {
1609 return m_LSL_Functions.llEscapeURL(url);
1610 }
1611
1612 public string llUnescapeURL(string url)
1613 {
1614 return m_LSL_Functions.llUnescapeURL(url);
1615 }
1616
1617 public void llMapDestination(string simname, vector pos, vector look_at)
1618 {
1619 m_LSL_Functions.llMapDestination(simname, pos, look_at);
1620 }
1621
1622 public void llAddToLandBanList(string avatar, double hours)
1623 {
1624 m_LSL_Functions.llAddToLandBanList(avatar, hours);
1625 }
1626
1627 public void llRemoveFromLandPassList(string avatar)
1628 {
1629 m_LSL_Functions.llRemoveFromLandPassList(avatar);
1630 }
1631
1632 public void llRemoveFromLandBanList(string avatar)
1633 {
1634 m_LSL_Functions.llRemoveFromLandBanList(avatar);
1635 }
1636
1637 public void llSetCameraParams(LSL_Types.list rules)
1638 {
1639 m_LSL_Functions.llSetCameraParams(rules);
1640 }
1641
1642 public void llClearCameraParams()
1643 {
1644 m_LSL_Functions.llClearCameraParams();
1645 }
1646
1647 public double llListStatistics(int operation, LSL_Types.list src)
1648 {
1649 return m_LSL_Functions.llListStatistics(operation, src);
1650 }
1651
1652 public LSL_Types.LSLInteger llGetUnixTime()
1653 {
1654 return m_LSL_Functions.llGetUnixTime();
1655 }
1656
1657 public LSL_Types.LSLInteger llGetParcelFlags(vector pos)
1658 {
1659 return m_LSL_Functions.llGetParcelFlags(pos);
1660 }
1661
1662 public LSL_Types.LSLInteger llGetRegionFlags()
1663 {
1664 return m_LSL_Functions.llGetRegionFlags();
1665 }
1666
1667 public string llXorBase64StringsCorrect(string str1, string str2)
1668 {
1669 return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2);
1670 }
1671
1672 public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
1673 {
1674 return m_LSL_Functions.llHTTPRequest(url, parameters, body);
1675 }
1676
1677 public void llResetLandBanList()
1678 {
1679 m_LSL_Functions.llResetLandBanList();
1680 }
1681
1682 public void llResetLandPassList()
1683 {
1684 m_LSL_Functions.llResetLandPassList();
1685 }
1686
1687 public LSL_Types.LSLInteger llGetParcelPrimCount(vector pos, int category, int sim_wide)
1688 {
1689 return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide);
1690 }
1691
1692 public LSL_Types.list llGetParcelPrimOwners(vector pos)
1693 {
1694 return m_LSL_Functions.llGetParcelPrimOwners(pos);
1695 }
1696
1697 public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id)
1698 {
1699 return m_LSL_Functions.llGetObjectPrimCount(object_id);
1700 }
1701
1702 public LSL_Types.LSLInteger llGetParcelMaxPrims(vector pos, int sim_wide)
1703 {
1704 return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide);
1705 }
1706
1707 public LSL_Types.list llGetParcelDetails(vector pos, LSL_Types.list param)
1708 {
1709 return m_LSL_Functions.llGetParcelDetails(pos, param);
1710 }
1711
1712 public void llSetLinkTexture(int linknumber, string texture, int face)
1713 {
1714 m_LSL_Functions.llSetLinkTexture(linknumber, texture, face);
1715 }
1716
1717 public string llStringTrim(string src, int type)
1718 {
1719 return m_LSL_Functions.llStringTrim(src, type);
1720 }
1721
1722 public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args)
1723 {
1724 return m_LSL_Functions.llGetObjectDetails(id, args);
1725 }
1726
1727 public double llList2Float(LSL_Types.list src, int index)
1728 {
1729 return m_LSL_Functions.llList2Float(src, index);
1730 }
1731 }
1732}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
new file mode 100644
index 0000000..168804d
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -0,0 +1,199 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.ScriptEngine.Interfaces;
36using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
37using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
38using key = System.String;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41
42namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
43{
44 public partial class ScriptBaseClass : MarshalByRefObject
45 {
46 public IOSSL_Api m_OSSL_Functions;
47
48 public void ApiTypeOSSL(IScriptApi api)
49 {
50 if(!(api is IOSSL_Api))
51 return;
52
53 m_OSSL_Functions = (IOSSL_Api)api;
54 }
55
56 public void osSetRegionWaterHeight(double height)
57 {
58 m_OSSL_Functions.osSetRegionWaterHeight(height);
59 }
60
61 public double osList2Double(LSL_Types.list src, int index)
62 {
63 return m_OSSL_Functions.osList2Double(src, index);
64 }
65
66 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
67 int timer)
68 {
69 return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
70 }
71
72 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
73 int timer)
74 {
75 return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
76 }
77
78 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
79 int timer, int alpha)
80 {
81 return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
82 }
83
84 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
85 int timer, int alpha)
86 {
87 return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
88 }
89
90 public double osTerrainGetHeight(int x, int y)
91 {
92 return m_OSSL_Functions.osTerrainGetHeight(x, y);
93 }
94
95 public int osTerrainSetHeight(int x, int y, double val)
96 {
97 return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
98 }
99
100 public int osRegionRestart(double seconds)
101 {
102 return m_OSSL_Functions.osRegionRestart(seconds);
103 }
104
105 public void osRegionNotice(string msg)
106 {
107 m_OSSL_Functions.osRegionNotice(msg);
108 }
109
110 public bool osConsoleCommand(string Command)
111 {
112 return m_OSSL_Functions.osConsoleCommand(Command);
113 }
114
115 public void osSetParcelMediaURL(string url)
116 {
117 m_OSSL_Functions.osSetParcelMediaURL(url);
118 }
119
120 public void osSetPrimFloatOnWater(int floatYN)
121 {
122 m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
123 }
124
125 // Animation Functions
126
127 public void osAvatarPlayAnimation(string avatar, string animation)
128 {
129 m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
130 }
131
132 public void osAvatarStopAnimation(string avatar, string animation)
133 {
134 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
135 }
136
137
138 //Texture Draw functions
139
140 public string osMovePen(string drawList, int x, int y)
141 {
142 return m_OSSL_Functions.osMovePen(drawList, x, y);
143 }
144
145 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
146 {
147 return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
148 }
149
150 public string osDrawLine(string drawList, int endX, int endY)
151 {
152 return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
153 }
154
155 public string osDrawText(string drawList, string text)
156 {
157 return m_OSSL_Functions.osDrawText(drawList, text);
158 }
159
160 public string osDrawEllipse(string drawList, int width, int height)
161 {
162 return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
163 }
164
165 public string osDrawRectangle(string drawList, int width, int height)
166 {
167 return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
168 }
169
170 public string osDrawFilledRectangle(string drawList, int width, int height)
171 {
172 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
173 }
174
175 public string osSetFontSize(string drawList, int fontSize)
176 {
177 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
178 }
179
180 public string osSetPenSize(string drawList, int penSize)
181 {
182 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
183 }
184
185 public string osSetPenColour(string drawList, string colour)
186 {
187 return m_OSSL_Functions.osSetPenColour(drawList, colour);
188 }
189
190 public string osDrawImage(string drawList, int width, int height, string imageUrl)
191 {
192 return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
193 }
194 public void osSetStateEvents(int events)
195 {
196 m_OSSL_Functions.osSetStateEvents(events);
197 }
198 }
199}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj
new file mode 100644
index 0000000..870da9f
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj
@@ -0,0 +1,161 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>9.0.21022</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{21BC44EA-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Region.ScriptEngine.Shared.Api.Runtime</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Region.ScriptEngine.Shared.Api.Runtime</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\..\..\..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="log4net.dll" >
70 <HintPath>..\..\..\..\..\..\bin\log4net.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Nini.dll" >
74 <HintPath>..\..\..\..\..\..\bin\Nini.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Nini.dll" >
78 <HintPath>..\..\..\..\..\..\bin\Nini.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="RAIL.dll" >
82 <HintPath>..\..\..\..\..\..\bin\RAIL.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="System" >
86 <HintPath>System.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 <Reference Include="System.Data" >
90 <HintPath>System.Data.dll</HintPath>
91 <Private>False</Private>
92 </Reference>
93 <Reference Include="System.Web" >
94 <HintPath>System.Web.dll</HintPath>
95 <Private>False</Private>
96 </Reference>
97 <Reference Include="System.Xml" >
98 <HintPath>System.Xml.dll</HintPath>
99 <Private>False</Private>
100 </Reference>
101 </ItemGroup>
102 <ItemGroup>
103 <ProjectReference Include="..\..\..\..\Application\OpenSim.csproj">
104 <Name>OpenSim</Name>
105 <Project>{438A9556-0000-0000-0000-000000000000}</Project>
106 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
107 <Private>False</Private>
108 </ProjectReference>
109 <ProjectReference Include="..\..\..\..\..\Framework\OpenSim.Framework.csproj">
110 <Name>OpenSim.Framework</Name>
111 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
112 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
113 <Private>False</Private>
114 </ProjectReference>
115 <ProjectReference Include="..\..\..\..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
116 <Name>OpenSim.Framework.Communications</Name>
117 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
118 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
119 <Private>False</Private>
120 </ProjectReference>
121 <ProjectReference Include="..\..\..\..\..\Framework\Console\OpenSim.Framework.Console.csproj">
122 <Name>OpenSim.Framework.Console</Name>
123 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
124 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
125 <Private>False</Private>
126 </ProjectReference>
127 <ProjectReference Include="..\..\..\..\Environment\OpenSim.Region.Environment.csproj">
128 <Name>OpenSim.Region.Environment</Name>
129 <Project>{DCBA491C-0000-0000-0000-000000000000}</Project>
130 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
131 <Private>False</Private>
132 </ProjectReference>
133 <ProjectReference Include="..\..\OpenSim.Region.ScriptEngine.Shared.csproj">
134 <Name>OpenSim.Region.ScriptEngine.Shared</Name>
135 <Project>{D9F1B557-0000-0000-0000-000000000000}</Project>
136 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
137 <Private>False</Private>
138 </ProjectReference>
139 </ItemGroup>
140 <ItemGroup>
141 <Compile Include="LSL_Constants.cs">
142 <SubType>Code</SubType>
143 </Compile>
144 <Compile Include="LSL_Stub.cs">
145 <SubType>Code</SubType>
146 </Compile>
147 <Compile Include="OSSL_Stub.cs">
148 <SubType>Code</SubType>
149 </Compile>
150 <Compile Include="ScriptBase.cs">
151 <SubType>Code</SubType>
152 </Compile>
153 </ItemGroup>
154 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
155 <PropertyGroup>
156 <PreBuildEvent>
157 </PreBuildEvent>
158 <PostBuildEvent>
159 </PostBuildEvent>
160 </PropertyGroup>
161</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user
new file mode 100644
index 0000000..c28f556
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\Data\OpenSim\bin\</ReferencePath>
6 <LastOpenVersion>9.0.21022</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build
new file mode 100644
index 0000000..c3af05c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll.build
@@ -0,0 +1,62 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}" flatten="true">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <copy todir="${project::get-base-directory()}/${build.dir}">
11 <fileset basedir=".">
12 </fileset>
13 </copy>
14 <csc target="library" debug="${build.debug}" unsafe="False" warnaserror="False" define="TRACE;DEBUG" main="" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
15 <resources prefix="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" dynamicprefix="true" >
16 </resources>
17 <sources failonempty="true">
18 <include name="LSL_Constants.cs" />
19 <include name="LSL_Stub.cs" />
20 <include name="OSSL_Stub.cs" />
21 <include name="ScriptBase.cs" />
22 </sources>
23 <references basedir="${project::get-base-directory()}">
24 <lib>
25 <include name="${project::get-base-directory()}" />
26 <include name="${project::get-base-directory()}/${build.dir}" />
27 </lib>
28 <include name="../../../../../../bin/Axiom.MathLib.dll" />
29 <include name="../../../../../../bin/libsecondlife.dll" />
30 <include name="../../../../../../bin/log4net.dll" />
31 <include name="../../../../../../bin/Nini.dll" />
32 <include name="../../../../../../bin/Nini.dll" />
33 <include name="../../../../../../bin/OpenSim.exe" />
34 <include name="../../../../../../bin/OpenSim.Framework.dll" />
35 <include name="../../../../../../bin/OpenSim.Framework.Communications.dll" />
36 <include name="../../../../../../bin/OpenSim.Framework.Console.dll" />
37 <include name="../../../../../../bin/OpenSim.Region.Environment.dll" />
38 <include name="../../../../../../bin/OpenSim.Region.ScriptEngine.Shared.dll" />
39 <include name="../../../../../../bin/RAIL.dll" />
40 <include name="System.dll" />
41 <include name="System.Data.dll" />
42 <include name="System.Web.dll" />
43 <include name="System.Xml.dll" />
44 </references>
45 </csc>
46 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../../../../bin/" />
47 <mkdir dir="${project::get-base-directory()}/../../../../../../bin/"/>
48 <copy todir="${project::get-base-directory()}/../../../../../../bin/">
49 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
50 <include name="*.dll"/>
51 <include name="*.exe"/>
52 <include name="*.mdb"/>
53 </fileset>
54 </copy>
55 </target>
56 <target name="clean">
57 <delete dir="${obj.dir}" failonerror="false" />
58 <delete dir="${bin.dir}" failonerror="false" />
59 </target>
60 <target name="doc" description="Creates documentation.">
61 </target>
62</project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
new file mode 100644
index 0000000..37bedfc
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
@@ -0,0 +1,43 @@
1<Project name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" description="" standardNamespace="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" newfilesearch="None" enableviewstate="True" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4 <Output directory="./../../../../../../bin/" assembly="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
5 <Build debugmode="True" target="Library" />
6 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
7 <CodeGeneration compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="TRACE;DEBUG" generatexmldocumentation="False" win32Icon="" ctype="CSharpCompilerParameters" />
8 </Configuration>
9 <Configuration name="Release" ctype="DotNetProjectConfiguration">
10 <Output directory="./../../../../../../bin/" assembly="OpenSim.Region.ScriptEngine.Shared.Api.Runtime" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
11 <Build debugmode="True" target="Library" />
12 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
13 <CodeGeneration compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="TRACE" generatexmldocumentation="False" win32Icon="" ctype="CSharpCompilerParameters" />
14 </Configuration>
15 </Configurations>
16 <DeploymentInformation target="" script="" strategy="File">
17 <excludeFiles />
18 </DeploymentInformation>
19 <Contents>
20 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
22 <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
23 <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
24 </Contents>
25 <References>
26 <ProjectReference type="Assembly" refto="../../../../../../bin/Axiom.MathLib.dll" localcopy="False" />
27 <ProjectReference type="Assembly" refto="../../../../../../bin/libsecondlife.dll" localcopy="False" />
28 <ProjectReference type="Assembly" refto="../../../../../../bin/log4net.dll" localcopy="False" />
29 <ProjectReference type="Assembly" refto="../../../../../../bin/Nini.dll" localcopy="False" />
30 <ProjectReference type="Assembly" refto="../../../../../../bin/Nini.dll" localcopy="False" />
31 <ProjectReference type="Project" localcopy="False" refto="OpenSim" />
32 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework" />
33 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework.Communications" />
34 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Framework.Console" />
35 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Region.Environment" />
36 <ProjectReference type="Project" localcopy="False" refto="OpenSim.Region.ScriptEngine.Shared" />
37 <ProjectReference type="Assembly" refto="../../../../../../bin/RAIL.dll" localcopy="False" />
38 <ProjectReference type="Gac" localcopy="False" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
39 <ProjectReference type="Gac" localcopy="False" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
40 <ProjectReference type="Gac" localcopy="False" refto="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
41 <ProjectReference type="Gac" localcopy="False" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
42 </References>
43</Project>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
new file mode 100644
index 0000000..aa2c9c2
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.ScriptEngine.Interfaces;
35using OpenSim.Region.ScriptEngine.Shared;
36
37namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
38{
39 public partial class ScriptBaseClass : MarshalByRefObject, IScript
40 {
41 private Dictionary<string,MethodInfo> inits = new Dictionary<string,MethodInfo>();
42
43 public ScriptBaseClass()
44 {
45 MethodInfo[] myArrayMethodInfo = GetType().GetMethods(BindingFlags.Public|BindingFlags.Instance);
46
47 foreach(MethodInfo mi in myArrayMethodInfo)
48 {
49 if(mi.Name.Length > 7 && mi.Name.Substring(0, 7) == "ApiType")
50 {
51 string type=mi.Name.Substring(7);
52 inits[type]=mi;
53 }
54 }
55 }
56
57 public string[] GetApis()
58 {
59 string[] apis = new string[inits.Count];
60 inits.Keys.CopyTo(apis, 0);
61 return apis;
62 }
63
64 public void InitApi(string api, IScriptApi data)
65 {
66 if(!inits.ContainsKey(api))
67 return;
68
69 MethodInfo mi = inits[api];
70
71 Object[] args = new Object[1];
72 args[0] = data;
73
74 mi.Invoke(this, args);
75 }
76
77 private Dictionary<string, object> m_InitialValues =
78 new Dictionary<string, object>();
79 private Dictionary<string, FieldInfo> m_Fields =
80 new Dictionary<string, FieldInfo>();
81
82 public Dictionary<string, object> GetVars()
83 {
84 Dictionary<string, object> vars = new Dictionary<string, object>();
85
86 if (m_Fields == null)
87 return vars;
88
89 m_Fields.Clear();
90
91 Type t = GetType();
92
93 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
94 BindingFlags.Public |
95 BindingFlags.Instance |
96 BindingFlags.DeclaredOnly);
97
98 foreach (FieldInfo field in fields)
99 {
100 m_Fields[field.Name]=field;
101
102 vars[field.Name]=field.GetValue(this);
103 }
104
105 return vars;
106 }
107
108 public void SetVars(Dictionary<string, object> vars)
109 {
110 foreach (KeyValuePair<string, object> var in vars)
111 {
112 if (m_Fields.ContainsKey(var.Key))
113 {
114 m_Fields[var.Key].SetValue(this, var.Value);
115 }
116 }
117 }
118
119 public void ResetVars()
120 {
121 SetVars(m_InitialValues);
122 }
123 }
124}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs
new file mode 100644
index 0000000..27ab04e
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Atom.cs
@@ -0,0 +1,218 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33using System.Text;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 public class Atom : IUnifiable
38 {
39 private static Dictionary<string, Atom> _atomStore = new Dictionary<string, Atom>();
40 public readonly string _name;
41 public readonly Atom _module;
42
43 /// <summary>
44 /// You should not call this constructor, but use Atom.a instead.
45 /// </summary>
46 /// <param name="name"></param>
47 /// <param name="module"></param>
48 private Atom(string name, Atom module)
49 {
50 _name = name;
51 _module = module;
52 }
53
54 /// <summary>
55 /// Return the unique Atom object for name where module is null. You should use this to create
56 /// an Atom instead of calling the Atom constructor.
57 /// </summary>
58 /// <param name="name"></param>
59 /// <returns></returns>
60 public static Atom a(string name)
61 {
62 Atom atom;
63 if (!_atomStore.TryGetValue(name, out atom))
64 {
65 atom = new Atom(name, null);
66 _atomStore[name] = atom;
67 }
68 return atom;
69 }
70
71 /// <summary>
72 /// Return an Atom object with the name and module. If module is null or Atom.NIL,
73 /// this behaves like Atom.a(name) and returns the unique object where the module is null.
74 /// If module is not null or Atom.NIL, this may or may not be the same object as another Atom
75 /// with the same name and module.
76 /// </summary>
77 /// <param name="name"></param>
78 /// <param name="module"></param>
79 /// <returns></returns>
80 public static Atom a(string name, Atom module)
81 {
82 if (module == null || module == Atom.NIL)
83 return a(name);
84 return new Atom(name, module);
85 }
86
87 /// <summary>
88 /// If Obj is an Atom unify its _module with Module. If the Atom's _module is null, use Atom.NIL.
89 /// </summary>
90 /// <param name="Atom"></param>
91 /// <param name="Module"></param>
92 /// <returns></returns>
93 public static IEnumerable<bool> module(object Obj, object Module)
94 {
95 Obj = YP.getValue(Obj);
96 if (Obj is Atom)
97 {
98 if (((Atom)Obj)._module == null)
99 return YP.unify(Module, Atom.NIL);
100 else
101 return YP.unify(Module, ((Atom)Obj)._module);
102 }
103 return YP.fail();
104 }
105
106 public static readonly Atom NIL = Atom.a("[]");
107 public static readonly Atom DOT = Atom.a(".");
108 public static readonly Atom F = Atom.a("f");
109 public static readonly Atom SLASH = Atom.a("/");
110 public static readonly Atom HAT = Atom.a("^");
111 public static readonly Atom RULE = Atom.a(":-");
112
113 public IEnumerable<bool> unify(object arg)
114 {
115 arg = YP.getValue(arg);
116 if (arg is Atom)
117 return Equals(arg) ? YP.succeed() : YP.fail();
118 else if (arg is Variable)
119 return ((Variable)arg).unify(this);
120 else
121 return YP.fail();
122 }
123
124 public void addUniqueVariables(List<Variable> variableSet)
125 {
126 // Atom does not contain variables.
127 }
128
129 public object makeCopy(Variable.CopyStore copyStore)
130 {
131 // Atom does not contain variables that need to be copied.
132 return this;
133 }
134
135 public bool termEqual(object term)
136 {
137 return Equals(YP.getValue(term));
138 }
139
140 public bool ground()
141 {
142 // Atom is always ground.
143 return true;
144 }
145
146 public override bool Equals(object obj)
147 {
148 if (obj is Atom)
149 {
150 if (_module == null && ((Atom)obj)._module == null)
151 // When _declaringClass is null, we always use an identical object from _atomStore.
152 return this == obj;
153 // Otherwise, ignore _declaringClass and do a normal string compare on the _name.
154 return _name == ((Atom)obj)._name;
155 }
156 return false;
157 }
158
159 public override string ToString()
160 {
161 return _name;
162 }
163
164 public override int GetHashCode()
165 {
166 // Debug: need to check _declaringClass.
167 return _name.GetHashCode();
168 }
169
170 public string toQuotedString()
171 {
172 if (_name.Length == 0)
173 return "''";
174 else if (this == Atom.NIL)
175 return "[]";
176
177 StringBuilder result = new StringBuilder(_name.Length);
178 bool useQuotes = false;
179 foreach (char c in _name)
180 {
181 int cInt = (int)c;
182 if (c == '\'')
183 {
184 result.Append("''");
185 useQuotes = true;
186 }
187 else if (c == '_' || cInt >= (int)'a' && cInt <= (int)'z' ||
188 cInt >= (int)'A' && cInt <= (int)'Z' || cInt >= (int)'0' && cInt <= (int)'9')
189 result.Append(c);
190 else
191 {
192 // Debug: Need to handle non-printable chars.
193 result.Append(c);
194 useQuotes = true;
195 }
196 }
197
198 if (!useQuotes && (int)_name[0] >= (int)'a' && (int)_name[0] <= (int)'z')
199 return result.ToString();
200 else
201 {
202 // Surround in single quotes.
203 result.Append('\'');
204 return "'" + result;
205 }
206 }
207
208 /// <summary>
209 /// Return true if _name is lexicographically less than atom._name.
210 /// </summary>
211 /// <param name="atom"></param>
212 /// <returns></returns>
213 public bool lessThan(Atom atom)
214 {
215 return _name.CompareTo(atom._name) < 0;
216 }
217 }
218}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
new file mode 100644
index 0000000..70c1b5a
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
@@ -0,0 +1,234 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// A BagofAnswers holds answers for bagof and setof.
39 /// </summary>
40 public class BagofAnswers
41 {
42 private object _template;
43 private Variable[] _freeVariables;
44 private Dictionary<object[], List<object>> _bagForFreeVariables;
45 private List<object> _findallBagArray;
46 private static TermArrayEqualityComparer _termArrayEqualityComparer =
47 new TermArrayEqualityComparer();
48
49 /// <summary>
50 /// To get the free variables, split off any existential qualifiers from Goal such as the X in
51 /// "X ^ f(Y)", get the set of unbound variables in Goal that are not qualifiers, then remove
52 /// the unbound variables that are qualifiers as well as the unbound variables in Template.
53 /// </summary>
54 /// <param name="Template"></param>
55 /// <param name="Goal"></param>
56 public BagofAnswers(object Template, object Goal)
57 {
58 _template = Template;
59
60 // First get the set of variables that are not free variables.
61 List<Variable> variableSet = new List<Variable>();
62 YP.addUniqueVariables(Template, variableSet);
63 object UnqualifiedGoal = YP.getValue(Goal);
64 while (UnqualifiedGoal is Functor2 && ((Functor2)UnqualifiedGoal)._name == Atom.HAT)
65 {
66 YP.addUniqueVariables(((Functor2)UnqualifiedGoal)._arg1, variableSet);
67 UnqualifiedGoal = YP.getValue(((Functor2)UnqualifiedGoal)._arg2);
68 }
69
70 // Remember how many non-free variables there are so we can find the unique free variables
71 // that are added.
72 int nNonFreeVariables = variableSet.Count;
73 YP.addUniqueVariables(UnqualifiedGoal, variableSet);
74 int nFreeVariables = variableSet.Count - nNonFreeVariables;
75 if (nFreeVariables == 0)
76 {
77 // There were no free variables added, so we won't waste time with _bagForFreeVariables.
78 _freeVariables = null;
79 _findallBagArray = new List<object>();
80 }
81 else
82 {
83 // Copy the free variables.
84 _freeVariables = new Variable[nFreeVariables];
85 for (int i = 0; i < nFreeVariables; ++i)
86 _freeVariables[i] = variableSet[i + nNonFreeVariables];
87
88 _bagForFreeVariables = new Dictionary<object[], List<object>>(_termArrayEqualityComparer);
89 }
90 }
91
92 public void add()
93 {
94 if (_freeVariables == null)
95 // The goal has bound the values in _template but we don't bother with _freeVariables.
96 _findallBagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
97 else
98 {
99 // The goal has bound the values in _template and _freeVariables.
100 // Find the entry for this set of _freeVariables values.
101 object[] freeVariableValues = new object[_freeVariables.Length];
102 for (int i = 0; i < _freeVariables.Length; ++i)
103 freeVariableValues[i] = YP.getValue(_freeVariables[i]);
104 List<object> bagArray;
105 if (!_bagForFreeVariables.TryGetValue(freeVariableValues, out bagArray))
106 {
107 bagArray = new List<object>();
108 _bagForFreeVariables[freeVariableValues] = bagArray;
109 }
110
111 // Now copy the template and add to the bag for the freeVariables values.
112 bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
113 }
114 }
115
116 /// <summary>
117 /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag.
118 /// </summary>
119 /// <param name="bagArrayVariable">this is unified with the List<object> of matches for template that
120 /// corresponds to the bindings for freeVariables. Be very careful: this does not unify with a Prolog
121 /// list.</param>
122 /// <returns></returns>
123 public IEnumerable<bool> resultArray(Variable bagArrayVariable)
124 {
125 if (_freeVariables == null)
126 {
127 // No unbound free variables, so we only filled one bag. If empty, bagof fails.
128 if (_findallBagArray.Count > 0)
129 {
130 foreach (bool l1 in bagArrayVariable.unify(_findallBagArray))
131 yield return false;
132 }
133 }
134 else
135 {
136 foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables)
137 {
138 foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key))
139 {
140 foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value))
141 yield return false;
142 }
143 // Debug: Should we free memory of the answers already returned?
144 }
145 }
146 }
147
148 /// <summary>
149 /// For each result, unify the _freeVariables and unify Bag with the associated bag.
150 /// </summary>
151 /// <param name="Bag"></param>
152 /// <returns></returns>
153 public IEnumerable<bool> result(object Bag)
154 {
155 Variable bagArrayVariable = new Variable();
156 foreach (bool l1 in resultArray(bagArrayVariable))
157 {
158 foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue())))
159 yield return false;
160 }
161 }
162
163 /// <summary>
164 /// For each result, unify the _freeVariables and unify Bag with the associated bag which is sorted
165 /// with duplicates removed, as in setof.
166 /// </summary>
167 /// <param name="Bag"></param>
168 /// <returns></returns>
169 public IEnumerable<bool> resultSet(object Bag)
170 {
171 Variable bagArrayVariable = new Variable();
172 foreach (bool l1 in resultArray(bagArrayVariable))
173 {
174 List<object> bagArray = (List<object>)bagArrayVariable.getValue();
175 YP.sortArray(bagArray);
176 foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray)))
177 yield return false;
178 }
179 }
180
181 public static IEnumerable<bool> bagofArray
182 (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable)
183 {
184 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
185 foreach (bool l1 in goalIterator)
186 bagOfAnswers.add();
187 return bagOfAnswers.resultArray(bagArrayVariable);
188 }
189
190 public static IEnumerable<bool> bagof
191 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
192 {
193 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
194 foreach (bool l1 in goalIterator)
195 bagOfAnswers.add();
196 return bagOfAnswers.result(Bag);
197 }
198
199 public static IEnumerable<bool> setof
200 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
201 {
202 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
203 foreach (bool l1 in goalIterator)
204 bagOfAnswers.add();
205 return bagOfAnswers.resultSet(Bag);
206 }
207
208 /// <summary>
209 /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual.
210 /// </summary>
211 private class TermArrayEqualityComparer : IEqualityComparer<object[]>
212 {
213 public bool Equals(object[] array1, object[] array2)
214 {
215 if (array1.Length != array2.Length)
216 return false;
217 for (int i = 0; i < array1.Length; ++i)
218 {
219 if (!YP.termEqual(array1[i], array2[i]))
220 return false;
221 }
222 return true;
223 }
224
225 public int GetHashCode(object[] array)
226 {
227 int hashCode = 0;
228 for (int i = 0; i < array.Length; ++i)
229 hashCode ^= array[i].GetHashCode();
230 return hashCode;
231 }
232 }
233 }
234}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
new file mode 100644
index 0000000..28709e1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
@@ -0,0 +1,103 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// A FindallAnswers holds answers for findall.
39 /// </summary>
40 public class FindallAnswers
41 {
42 private object _template;
43 private List<object> _bagArray;
44
45 public FindallAnswers(object Template)
46 {
47 _template = Template;
48 _bagArray = new List<object>();
49 }
50
51 public void add()
52 {
53 _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
54 }
55
56 public List<object> resultArray()
57 {
58 return _bagArray;
59 }
60
61 /// <summary>
62 /// Unify Bag with the result. This frees the internal answers, so you can only call this once.
63 /// </summary>
64 /// <param name="Bag"></param>
65 /// <returns></returns>
66 public IEnumerable<bool> result(object Bag)
67 {
68 object result = ListPair.make(_bagArray);
69 // Try to free the memory.
70 _bagArray = null;
71 return YP.unify(Bag, result);
72 }
73
74 /// <summary>
75 /// This is a simplified findall when the goal is a single call.
76 /// </summary>
77 /// <param name="Template"></param>
78 /// <param name="goal"></param>
79 /// <param name="Bag"></param>
80 /// <returns></returns>
81 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
82 {
83 FindallAnswers findallAnswers = new FindallAnswers(Template);
84 foreach (bool l1 in goal)
85 findallAnswers.add();
86 return findallAnswers.result(Bag);
87 }
88
89 /// <summary>
90 /// Like findall, except return an array of the results.
91 /// </summary>
92 /// <param name="template"></param>
93 /// <param name="goal"></param>
94 /// <returns></returns>
95 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
96 {
97 FindallAnswers findallAnswers = new FindallAnswers(Template);
98 foreach (bool l1 in goal)
99 findallAnswers.add();
100 return findallAnswers.resultArray();
101 }
102 }
103}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
new file mode 100644
index 0000000..8ef8de0
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
@@ -0,0 +1,188 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object[] _args;
40
41 public Functor(Atom name, object[] args)
42 {
43 if (args.Length <= 3)
44 {
45 if (args.Length == 0)
46 throw new Exception("For arity 0 functor, just use name as an Atom");
47 else if (args.Length == 1)
48 throw new Exception("For arity 1 functor, use Functor1");
49 else if (args.Length == 2)
50 throw new Exception("For arity 2 functor, use Functor2");
51 else if (args.Length == 3)
52 throw new Exception("For arity 3 functor, use Functor3");
53 else
54 // (This shouldn't happen, but include it for completeness.
55 throw new Exception("Cannot create a Functor of arity " + args.Length);
56 }
57
58 _name = name;
59 _args = args;
60 }
61
62 public Functor(string name, object[] args)
63 : this(Atom.a(name), args)
64 {
65 }
66
67 /// <summary>
68 /// Return an Atom, Functor1, Functor2, Functor3 or Functor depending on the
69 /// length of args.
70 /// Note that this is different than the Functor constructor which requires
71 /// the length of args to be greater than 3.
72 /// </summary>
73 /// <param name="name"></param>
74 /// <param name="args"></param>
75 /// <returns></returns>
76 public static object make(Atom name, object[] args)
77 {
78 if (args.Length <= 0)
79 return name;
80 else if (args.Length == 1)
81 return new Functor1(name, args[0]);
82 else if (args.Length == 2)
83 return new Functor2(name, args[0], args[1]);
84 else if (args.Length == 3)
85 return new Functor3(name, args[0], args[1], args[2]);
86 else
87 return new Functor(name, args);
88 }
89
90 /// <summary>
91 /// Call the main make, first converting name to an Atom.
92 /// </summary>
93 /// <param name="name"></param>
94 /// <param name="args"></param>
95 /// <returns></returns>
96 public static object make(string name, object[] args)
97 {
98 return make(Atom.a(name), args);
99 }
100
101 public IEnumerable<bool> unify(object arg)
102 {
103 arg = YP.getValue(arg);
104 if (arg is Functor)
105 {
106 Functor argFunctor = (Functor)arg;
107 if (_name.Equals(argFunctor._name))
108 return YP.unifyArrays(_args, argFunctor._args);
109 else
110 return YP.fail();
111 }
112 else if (arg is Variable)
113 return ((Variable)arg).unify(this);
114 else
115 return YP.fail();
116 }
117
118 public override string ToString()
119 {
120 string result = _name + "(" + YP.getValue(_args[0]);
121 for (int i = 1; i < _args.Length; ++i)
122 result += ", " + YP.getValue(_args[i]);
123 result += ")";
124 return result;
125 }
126
127 public bool termEqual(object term)
128 {
129 term = YP.getValue(term);
130 if (term is Functor)
131 {
132 Functor termFunctor = (Functor)term;
133 if (_name.Equals(termFunctor._name) && _args.Length == termFunctor._args.Length)
134 {
135 for (int i = 0; i < _args.Length; ++i)
136 {
137 if (!YP.termEqual(_args[i], termFunctor._args[i]))
138 return false;
139 }
140 return true;
141 }
142 }
143 return false;
144 }
145
146 public bool lessThan(Functor functor)
147 {
148 // Do the equal check first since it is faster.
149 if (!_name.Equals(functor._name))
150 return _name.lessThan(functor._name);
151
152 if (_args.Length != functor._args.Length)
153 return _args.Length < functor._args.Length;
154
155 for (int i = 0; i < _args.Length; ++i)
156 {
157 if (!YP.termEqual(_args[i], functor._args[i]))
158 return YP.termLessThan(_args[i], functor._args[i]);
159 }
160
161 return false;
162 }
163
164 public bool ground()
165 {
166 for (int i = 0; i < _args.Length; ++i)
167 {
168 if (!YP.ground(_args[i]))
169 return false;
170 }
171 return true;
172 }
173
174 public void addUniqueVariables(List<Variable> variableSet)
175 {
176 for (int i = 0; i < _args.Length; ++i)
177 YP.addUniqueVariables(_args[i], variableSet);
178 }
179
180 public object makeCopy(Variable.CopyStore copyStore)
181 {
182 object[] argsCopy = new object[_args.Length];
183 for (int i = 0; i < _args.Length; ++i)
184 argsCopy[i] = YP.makeCopy(_args[i], copyStore);
185 return new Functor(_name, argsCopy);
186 }
187 }
188}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
new file mode 100644
index 0000000..3c0c1c4
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor1 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40
41 public Functor1(Atom name, object arg1)
42 {
43 _name = name;
44 _arg1 = arg1;
45 }
46
47 public Functor1(string name, object arg1)
48 : this(Atom.a(name), arg1)
49 {
50 }
51
52 public IEnumerable<bool> unify(object arg)
53 {
54 arg = YP.getValue(arg);
55 if (arg is Functor1)
56 {
57 Functor1 argFunctor = (Functor1)arg;
58 if (_name.Equals(argFunctor._name))
59 {
60 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
61 yield return false;
62 }
63 }
64 else if (arg is Variable)
65 {
66 foreach (bool l1 in ((Variable)arg).unify(this))
67 yield return false;
68 }
69 }
70
71 public override string ToString()
72 {
73 return _name + "(" + YP.getValue(_arg1) + ")";
74 }
75
76 public bool termEqual(object term)
77 {
78 term = YP.getValue(term);
79 if (term is Functor1)
80 {
81 Functor1 termFunctor = (Functor1)term;
82 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1);
83 }
84 return false;
85 }
86
87 public bool lessThan(Functor1 functor)
88 {
89 // Do the equal check first since it is faster.
90 if (!_name.Equals(functor._name))
91 return _name.lessThan(functor._name);
92
93 return YP.termLessThan(_arg1, functor._arg1);
94 }
95
96 public bool ground()
97 {
98 return YP.ground(_arg1);
99 }
100
101 public void addUniqueVariables(List<Variable> variableSet)
102 {
103 YP.addUniqueVariables(_arg1, variableSet);
104 }
105
106 public object makeCopy(Variable.CopyStore copyStore)
107 {
108 return new Functor1(_name, YP.makeCopy(_arg1, copyStore));
109 }
110 }
111}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
new file mode 100644
index 0000000..596b763
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
@@ -0,0 +1,154 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor2 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40 public readonly object _arg2;
41
42 public Functor2(Atom name, object arg1, object arg2)
43 {
44 _name = name;
45 _arg1 = arg1;
46 _arg2 = arg2;
47 }
48
49 public Functor2(string name, object arg1, object arg2)
50 : this(Atom.a(name), arg1, arg2)
51 {
52 }
53
54 public IEnumerable<bool> unify(object arg)
55 {
56 arg = YP.getValue(arg);
57 if (arg is Functor2)
58 {
59 Functor2 argFunctor = (Functor2)arg;
60 if (_name.Equals(argFunctor._name))
61 {
62 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
63 {
64 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
65 yield return false;
66 }
67 }
68 }
69 else if (arg is Variable)
70 {
71 foreach (bool l1 in ((Variable)arg).unify(this))
72 yield return false;
73 }
74 }
75
76 public override string ToString()
77 {
78 if (_name == Atom.DOT)
79 return listPairToString(this);
80 else
81 return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ")";
82 }
83
84 public bool termEqual(object term)
85 {
86 term = YP.getValue(term);
87 if (term is Functor2)
88 {
89 Functor2 termFunctor = (Functor2)term;
90 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1)
91 && YP.termEqual(_arg2, termFunctor._arg2);
92 }
93 return false;
94 }
95
96 public bool lessThan(Functor2 functor)
97 {
98 // Do the equal check first since it is faster.
99 if (!_name.Equals(functor._name))
100 return _name.lessThan(functor._name);
101
102 if (!YP.termEqual(_arg1, functor._arg1))
103 return YP.termLessThan(_arg1, functor._arg1);
104
105 return YP.termLessThan(_arg2, functor._arg2);
106 }
107
108 public bool ground()
109 {
110 return YP.ground(_arg1) && YP.ground(_arg2);
111 }
112
113 public void addUniqueVariables(List<Variable> variableSet)
114 {
115 YP.addUniqueVariables(_arg1, variableSet);
116 YP.addUniqueVariables(_arg2, variableSet);
117 }
118
119 public object makeCopy(Variable.CopyStore copyStore)
120 {
121 return new Functor2(_name, YP.makeCopy(_arg1, copyStore),
122 YP.makeCopy(_arg2, copyStore));
123 }
124
125 private static string listPairToString(Functor2 listPair)
126 {
127 string result = "[";
128 while (true)
129 {
130 object head = YP.getValue(listPair._arg1);
131 object tail = YP.getValue(listPair._arg2);
132 if (tail == (object)Atom.NIL)
133 {
134 result += head;
135 break;
136 }
137 else if (tail is Functor2 && ((Functor2)tail)._name == Atom.DOT)
138 {
139 result += head + ", ";
140 listPair = (Functor2)tail;
141 // Loop again.
142 }
143 else
144 {
145 // The list is not terminated with NIL.
146 result += head + "|" + tail;
147 break;
148 }
149 }
150 result += "]";
151 return result;
152 }
153 }
154}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
new file mode 100644
index 0000000..041cceb
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
@@ -0,0 +1,133 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Functor3 : IUnifiable
37 {
38 public readonly Atom _name;
39 public readonly object _arg1;
40 public readonly object _arg2;
41 public readonly object _arg3;
42
43 public Functor3(Atom name, object arg1, object arg2, object arg3)
44 {
45 _name = name;
46 _arg1 = arg1;
47 _arg2 = arg2;
48 _arg3 = arg3;
49 }
50
51 public Functor3(string name, object arg1, object arg2, object arg3)
52 : this(Atom.a(name), arg1, arg2, arg3)
53 {
54 }
55
56 public IEnumerable<bool> unify(object arg)
57 {
58 arg = YP.getValue(arg);
59 if (arg is Functor3)
60 {
61 Functor3 argFunctor = (Functor3)arg;
62 if (_name.Equals(argFunctor._name))
63 {
64 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
65 {
66 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
67 {
68 foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3))
69 yield return false;
70 }
71 }
72 }
73 }
74 else if (arg is Variable)
75 {
76 foreach (bool l1 in ((Variable)arg).unify(this))
77 yield return false;
78 }
79 }
80
81 public override string ToString()
82 {
83 return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " +
84 YP.getValue(_arg3) + ")";
85 }
86
87 public bool termEqual(object term)
88 {
89 term = YP.getValue(term);
90 if (term is Functor3)
91 {
92 Functor3 termFunctor = (Functor3)term;
93 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1)
94 && YP.termEqual(_arg2, termFunctor._arg2)
95 && YP.termEqual(_arg3, termFunctor._arg3);
96 }
97 return false;
98 }
99
100 public bool lessThan(Functor3 functor)
101 {
102 // Do the equal check first since it is faster.
103 if (!_name.Equals(functor._name))
104 return _name.lessThan(functor._name);
105
106 if (!YP.termEqual(_arg1, functor._arg1))
107 return YP.termLessThan(_arg1, functor._arg1);
108
109 if (!YP.termEqual(_arg2, functor._arg2))
110 return YP.termLessThan(_arg2, functor._arg2);
111
112 return YP.termLessThan(_arg3, functor._arg3);
113 }
114
115 public bool ground()
116 {
117 return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3);
118 }
119
120 public void addUniqueVariables(List<Variable> variableSet)
121 {
122 YP.addUniqueVariables(_arg1, variableSet);
123 YP.addUniqueVariables(_arg2, variableSet);
124 YP.addUniqueVariables(_arg3, variableSet);
125 }
126
127 public object makeCopy(Variable.CopyStore copyStore)
128 {
129 return new Functor3(_name, YP.makeCopy(_arg1, copyStore),
130 YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore));
131 }
132 }
133}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
new file mode 100644
index 0000000..1be73f7
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
@@ -0,0 +1,288 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// An IndexedAnswers holds answers to a query based on the values of index arguments.
39 /// </summary>
40 public class IndexedAnswers : YP.IClause
41 {
42 // addAnswer adds the answer here and indexes it later.
43 private List<object[]> _allAnswers = new List<object[]>();
44 // The key has the arity of answers with non-null values for each indexed arg. The value
45 // is a list of the matching answers. The signature is implicit in the pattern on non-null index args.
46 private Dictionary<HashedList, List<object[]>> _indexedAnswers =
47 new Dictionary<HashedList, List<object[]>>();
48 // Keeps track of whether we have started adding entries to _indexedAnswers for the signature.
49 private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>();
50 private const int MAX_INDEX_ARGS = 31;
51
52 public IndexedAnswers()
53 {
54 }
55
56 /// <summary>
57 /// Elements of answer must be ground, since arguments with unbound variables make this
58 /// into a dynamic rule which we don't index.
59 /// </summary>
60 /// <param name="answer"></param>
61 public void addAnswer(object[] answer)
62 {
63 // Store a copy of the answer array.
64 object[] answerCopy = new object[answer.Length];
65 Variable.CopyStore copyStore = new Variable.CopyStore();
66 for (int i = 0; i < answer.Length; ++i)
67 answerCopy[i] = YP.makeCopy(answer[i], copyStore);
68 if (copyStore.getNUniqueVariables() > 0)
69 throw new InvalidOperationException
70 ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() +
71 " unbound variables");
72 _allAnswers.Add(answerCopy);
73
74 // If match has already indexed answers for a signature, we need to add
75 // this to the existing indexed answers.
76 foreach (int signature in _gotAnswersForSignature.Keys)
77 indexAnswerForSignature(answerCopy, signature);
78 }
79
80 private void indexAnswerForSignature(object[] answer, int signature)
81 {
82 // First find out which of the answer values can be used as an index.
83 object[] indexValues = new object[answer.Length];
84 for (int i = 0; i < answer.Length; ++i)
85 {
86 // We limit the number of indexed args in a 32-bit signature.
87 if (i >= MAX_INDEX_ARGS)
88 indexValues[i] = null;
89 else
90 indexValues[i] = getIndexValue(YP.getValue(answer[i]));
91 }
92
93 // We need an entry in indexArgs from indexValues for each 1 bit in signature.
94 HashedList indexArgs = new HashedList(indexValues.Length);
95 for (int i = 0; i < indexValues.Length; ++i)
96 {
97 if ((signature & (1 << i)) == 0)
98 indexArgs.Add(null);
99 else
100 {
101 if (indexValues[i] == null)
102 // The signature wants an index value here, but we don't have one so
103 // we can't add it as an answer for this signature.
104 return;
105 else
106 indexArgs.Add(indexValues[i]);
107 }
108 }
109
110 // Add the answer to the answers list for indexArgs, creating the entry if needed.
111 List<object[]> answers;
112 if (!_indexedAnswers.TryGetValue(indexArgs, out answers))
113 {
114 answers = new List<object[]>();
115 _indexedAnswers[indexArgs] = answers;
116 }
117 answers.Add(answer);
118 }
119
120 public IEnumerable<bool> match(object[] arguments)
121 {
122 // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for
123 // each non-null index arg.
124 HashedList indexArgs = new HashedList(arguments.Length);
125 bool gotAllIndexArgs = true;
126 int signature = 0;
127 for (int i = 0; i < arguments.Length; ++i)
128 {
129 object indexValue = null;
130 if (i < MAX_INDEX_ARGS)
131 {
132 // We limit the number of args in a 32-bit signature.
133 indexValue = getIndexValue(YP.getValue(arguments[i]));
134 if (indexValue != null)
135 signature += (1 << i);
136 }
137 if (indexValue == null)
138 gotAllIndexArgs = false;
139 indexArgs.Add(indexValue);
140 }
141
142 List<object[]> answers;
143 if (signature == 0)
144 // No index args, so we have to match from _allAnswers.
145 answers = _allAnswers;
146 else
147 {
148 if (!_gotAnswersForSignature.ContainsKey(signature))
149 {
150 // We need to create the entry in _indexedAnswers.
151 foreach (object[] answer in _allAnswers)
152 indexAnswerForSignature(answer, signature);
153 // Mark that we did this signature.
154 _gotAnswersForSignature[signature] = null;
155 }
156 if (!_indexedAnswers.TryGetValue(indexArgs, out answers))
157 yield break;
158 }
159
160 if (gotAllIndexArgs)
161 {
162 // All the arguments were already bound, so we don't need to do bindings.
163 yield return false;
164 yield break;
165 }
166
167 // Find matches in answers.
168 IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length];
169 foreach (object[] answer in answers)
170 {
171 bool gotMatch = true;
172 int nIterators = 0;
173 // Try to bind all the arguments.
174 for (int i = 0; i < arguments.Length; ++i)
175 {
176 if (indexArgs[i] != null)
177 // We already matched this argument by looking up _indexedAnswers.
178 continue;
179
180 IEnumerator<bool> iterator = YP.unify(arguments[i], answer[i]).GetEnumerator();
181 iterators[nIterators++] = iterator;
182 // MoveNext() is true if YP.unify succeeds.
183 if (!iterator.MoveNext())
184 {
185 gotMatch = false;
186 break;
187 }
188 }
189
190 try
191 {
192 if (gotMatch)
193 yield return false;
194 }
195 finally
196 {
197 // Manually finalize all the iterators.
198 for (int i = 0; i < nIterators; ++i)
199 iterators[i].Dispose();
200 }
201 }
202 }
203
204 /// <summary>
205 /// A HashedList extends an ArrayList with methods to get a hash and to check equality
206 /// based on the elements of the list.
207 /// </summary>
208 public class HashedList : ArrayList
209 {
210 private bool _gotHashCode = false;
211 private int _hashCode;
212
213 public HashedList()
214 : base()
215 {
216 }
217
218 public HashedList(int capacity)
219 : base(capacity)
220 {
221 }
222
223 public HashedList(ICollection c)
224 : base(c)
225 {
226 }
227
228 // Debug: Should override all the other methods that change this.
229 public override int Add(object value)
230 {
231 _gotHashCode = false;
232 return base.Add(value);
233 }
234
235 public override int GetHashCode()
236 {
237 if (!_gotHashCode)
238 {
239 int hashCode = 1;
240 foreach (object obj in this)
241 hashCode = 31 * hashCode + (obj == null ? 0 : obj.GetHashCode());
242 _hashCode = hashCode;
243 _gotHashCode = true;
244 }
245 return _hashCode;
246 }
247
248 public override bool Equals(object obj)
249 {
250 if (!(obj is ArrayList))
251 return false;
252
253 ArrayList objList = (ArrayList)obj;
254 if (objList.Count != Count)
255 return false;
256
257 for (int i = 0; i < Count; ++i)
258 {
259 object value = objList[i];
260 if (value == null)
261 {
262 if (this[i] != null)
263 return false;
264 }
265 else
266 {
267 if (!value.Equals(this[i]))
268 return false;
269 }
270 }
271 return true;
272 }
273 }
274
275 /// <summary>
276 /// If we keep an index on value, return the value, or null if we don't index it.
277 /// </summary>
278 /// <param name="value">the term to examine. Assume you already called YP.getValue(value)</param>
279 /// <returns></returns>
280 public static object getIndexValue(object value)
281 {
282 if (value is Atom || value is string || value is Int32 || value is DateTime)
283 return value;
284 else
285 return null;
286 }
287 }
288}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
new file mode 100644
index 0000000..83ace2d
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
@@ -0,0 +1,156 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class ListPair : Functor2
37 {
38 public ListPair(object head, object tail) : base(Atom.DOT, head, tail)
39 {
40 }
41
42 public static object make(List<object> list)
43 {
44 if (list.Count <= 0)
45 return Atom.NIL;
46
47 object result = Atom.NIL;
48 // Start from the end.
49 for (int i = list.Count - 1; i >= 0; --i)
50 result = new ListPair(list[i], result);
51 return result;
52 }
53
54 public static object make(object[] array)
55 {
56 if (array.Length <= 0)
57 return Atom.NIL;
58
59 object result = Atom.NIL;
60 // Start from the end.
61 for (int i = array.Length - 1; i >= 0; --i)
62 result = new ListPair(array[i], result);
63 return result;
64 }
65
66 /// <summary>
67 /// Return a ListPair version of array, where repeated elements
68 /// (according to YP.termEqual) are removed.
69 /// </summary>
70 /// <param name="array"></param>
71 /// <returns></returns>
72 public static object makeWithoutRepeatedTerms(object[] array)
73 {
74 if (array.Length <= 0)
75 return Atom.NIL;
76
77 // Start from the end.
78 object previousTerm = array[array.Length - 1];
79 object result = new ListPair(previousTerm, Atom.NIL);
80 for (int i = array.Length - 2; i >= 0; --i)
81 {
82 object term = array[i];
83 if (YP.termEqual(term, previousTerm))
84 continue;
85 result = new ListPair(term, result);
86 previousTerm = term;
87 }
88 return result;
89 }
90
91 /// <summary>
92 /// Return a ListPair version of array, where repeated elements
93 /// (according to YP.termEqual) are removed.
94 /// </summary>
95 /// <param name="array"></param>
96 /// <returns></returns>
97 public static object makeWithoutRepeatedTerms(List<object> array)
98 {
99 if (array.Count <= 0)
100 return Atom.NIL;
101
102 // Start from the end.
103 object previousTerm = array[array.Count - 1];
104 object result = new ListPair(previousTerm, Atom.NIL);
105 for (int i = array.Count - 2; i >= 0; --i)
106 {
107 object term = array[i];
108 if (YP.termEqual(term, previousTerm))
109 continue;
110 result = new ListPair(term, result);
111 previousTerm = term;
112 }
113 return result;
114 }
115
116 public static object make(object element1)
117 {
118 return new ListPair(element1, Atom.NIL);
119 }
120
121 public static object make(object element1, object element2)
122 {
123 return new ListPair(element1, new ListPair(element2, Atom.NIL));
124 }
125
126 public static object make(object element1, object element2, object element3)
127 {
128 return new ListPair(element1,
129 new ListPair(element2, new ListPair(element3, Atom.NIL)));
130 }
131
132 /// <summary>
133 /// Return an array of the elements in list or null if it is not
134 /// a proper list. If list is Atom.NIL, return an array of zero elements.
135 /// This does not call YP.getValue on each element.
136 /// </summary>
137 /// <param name="list"></param>
138 /// <returns></returns>
139 public static object[] toArray(object list)
140 {
141 list = YP.getValue(list);
142 if (list.Equals(Atom.NIL))
143 return new object[0];
144
145 List<object> result = new List<object>();
146 for (object element = list;
147 element is Functor2 && ((Functor2)element)._name == Atom.DOT;
148 element = YP.getValue(((Functor2)element)._arg2))
149 result.Add(((Functor2)element)._arg1);
150
151 if (result.Count <= 0)
152 return null;
153 return result.ToArray();
154 }
155 }
156}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
new file mode 100644
index 0000000..105b556
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
@@ -0,0 +1,4457 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections.Generic;
33
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{
36 public class Parser
37 {
38 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
39 {
40 // Debug: Simple implementation for now.
41 YP.write(Format);
42 YP.write(Arguments);
43 YP.nl();
44 yield return false;
45 }
46
47 // Debug: Hand-modify this central predicate to do tail recursion.
48 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
49 {
50 bool repeat = true;
51 while (repeat)
52 {
53 repeat = false;
54 {
55 object C1 = arg1;
56 object Dict = arg2;
57 object Tokens = arg3;
58 Variable C2 = new Variable();
59 if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
60 {
61 if (YP.greaterThanOrEqual(C1, 0))
62 {
63 foreach (bool l4 in YP.get_code(C2))
64 {
65#if false
66 foreach (bool l5 in read_tokens(C2, Dict, Tokens))
67 {
68 yield return false;
69 }
70#endif
71 arg1 = YP.getValue(C2);
72 arg2 = YP.getValue(Dict);
73 arg3 = YP.getValue(Tokens);
74 repeat = true;
75 }
76 }
77 goto cutIf1;
78 }
79 if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
80 {
81 if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
82 {
83 foreach (bool l4 in read_identifier(C1, Dict, Tokens))
84 {
85 yield return false;
86 }
87 goto cutIf2;
88 }
89 }
90 if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
91 {
92 if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
93 {
94 foreach (bool l4 in read_variable(C1, Dict, Tokens))
95 {
96 yield return false;
97 }
98 goto cutIf3;
99 }
100 }
101 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
102 {
103 if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
104 {
105 foreach (bool l4 in read_number(C1, Dict, Tokens))
106 {
107 yield return false;
108 }
109 goto cutIf4;
110 }
111 }
112 if (YP.lessThan(C1, 127))
113 {
114 foreach (bool l3 in read_special(C1, Dict, Tokens))
115 {
116 yield return false;
117 }
118 goto cutIf5;
119 }
120 if (YP.lessThanOrEqual(C1, 160))
121 {
122 foreach (bool l3 in YP.get_code(C2))
123 {
124#if false
125 foreach (bool l4 in read_tokens(C2, Dict, Tokens))
126 {
127 yield return false;
128 }
129#endif
130 arg1 = YP.getValue(C2);
131 arg2 = YP.getValue(Dict);
132 arg3 = YP.getValue(Tokens);
133 repeat = true;
134 }
135 goto cutIf6;
136 }
137 if (YP.greaterThanOrEqual(C1, 223))
138 {
139 if (YP.notEqual(C1, 247))
140 {
141 foreach (bool l4 in read_identifier(C1, Dict, Tokens))
142 {
143 yield return false;
144 }
145 goto cutIf7;
146 }
147 }
148 if (YP.greaterThanOrEqual(C1, 192))
149 {
150 if (YP.notEqual(C1, 215))
151 {
152 foreach (bool l4 in read_variable(C1, Dict, Tokens))
153 {
154 yield return false;
155 }
156 goto cutIf8;
157 }
158 }
159 if (YP.notEqual(C1, 170))
160 {
161 if (YP.notEqual(C1, 186))
162 {
163 foreach (bool l4 in read_symbol(C1, Dict, Tokens))
164 {
165 yield return false;
166 }
167 goto cutIf9;
168 }
169 }
170 foreach (bool l2 in read_identifier(C1, Dict, Tokens))
171 {
172 yield return false;
173 }
174 cutIf9:
175 cutIf8:
176 cutIf7:
177 cutIf6:
178 cutIf5:
179 cutIf4:
180 cutIf3:
181 cutIf2:
182 cutIf1:
183 { }
184 }
185 }
186 }
187
188 // Compiler output follows.
189
190 class YPInnerClass { }
191 static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
192
193 public static IEnumerable<bool> parseInput(object TermList)
194 {
195 {
196 Variable TermAndVariables = new Variable();
197 FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
198 foreach (bool l2 in parseInputHelper(TermAndVariables))
199 {
200 findallAnswers1.add();
201 }
202 foreach (bool l2 in findallAnswers1.result(TermList))
203 {
204 yield return false;
205 }
206 }
207 }
208
209 public static IEnumerable<bool> parseInputHelper(object arg1)
210 {
211 {
212 Variable Term = new Variable();
213 Variable Variables = new Variable();
214 Variable Answer = new Variable();
215 Variable x4 = new Variable();
216 foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables)))
217 {
218 foreach (bool l3 in YP.repeat())
219 {
220 foreach (bool l4 in portable_read3(Answer, Variables, x4))
221 {
222 foreach (bool l5 in remove_pos(Answer, Term))
223 {
224 if (YP.termEqual(Term, Atom.a(@"end_of_file")))
225 {
226 yield break;
227 goto cutIf1;
228 }
229 yield return false;
230 cutIf1:
231 { }
232 }
233 }
234 }
235 }
236 }
237 }
238
239 public static IEnumerable<bool> clear_errors()
240 {
241 {
242 yield return false;
243 }
244 }
245
246 public static IEnumerable<bool> remove_pos(object arg1, object arg2)
247 {
248 {
249 Variable X = new Variable();
250 foreach (bool l2 in YP.unify(arg1, X))
251 {
252 foreach (bool l3 in YP.unify(arg2, X))
253 {
254 if (YP.var(X))
255 {
256 yield return true;
257 yield break;
258 }
259 }
260 }
261 }
262 {
263 object X = arg2;
264 Variable _Pos = new Variable();
265 Variable _Name = new Variable();
266 foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X)))
267 {
268 if (YP.var(X))
269 {
270 yield return true;
271 yield break;
272 }
273 }
274 }
275 {
276 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
277 {
278 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
279 {
280 yield return true;
281 yield break;
282 }
283 }
284 }
285 {
286 Variable H = new Variable();
287 Variable T = new Variable();
288 Variable NH = new Variable();
289 Variable NT = new Variable();
290 foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
291 {
292 foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT)))
293 {
294 foreach (bool l4 in remove_pos(H, NH))
295 {
296 foreach (bool l5 in remove_pos(T, NT))
297 {
298 yield return false;
299 }
300 }
301 yield break;
302 }
303 }
304 }
305 {
306 Variable A = new Variable();
307 Variable B = new Variable();
308 Variable NA = new Variable();
309 Variable NB = new Variable();
310 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
311 {
312 foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB)))
313 {
314 foreach (bool l4 in remove_pos(A, NA))
315 {
316 foreach (bool l5 in remove_pos(B, NB))
317 {
318 yield return false;
319 }
320 }
321 yield break;
322 }
323 }
324 }
325 {
326 Variable Atom_1 = new Variable();
327 Variable _F = new Variable();
328 foreach (bool l2 in YP.unify(arg1, Atom_1))
329 {
330 foreach (bool l3 in YP.unify(arg2, Atom_1))
331 {
332 foreach (bool l4 in YP.functor(Atom_1, _F, 0))
333 {
334 yield return false;
335 }
336 }
337 }
338 }
339 {
340 object Term = arg1;
341 object NewTerm = arg2;
342 Variable Func = new Variable();
343 Variable _Pos = new Variable();
344 Variable Args = new Variable();
345 Variable NArgs = new Variable();
346 if (YP.nonvar(Term))
347 {
348 foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args))))
349 {
350 foreach (bool l4 in remove_pos(Args, NArgs))
351 {
352 foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs)))
353 {
354 yield return false;
355 }
356 }
357 }
358 }
359 }
360 }
361
362 public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax)
363 {
364 {
365 foreach (bool l2 in portable_read(PosTerm, Syntax))
366 {
367 foreach (bool l3 in remove_pos(PosTerm, Term))
368 {
369 yield return false;
370 }
371 }
372 }
373 }
374
375 public static IEnumerable<bool> portable_read(object Answer, object Syntax)
376 {
377 {
378 Variable Tokens = new Variable();
379 Variable ParseTokens = new Variable();
380 foreach (bool l2 in read_tokens1(Tokens))
381 {
382 foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
383 {
384 foreach (bool l4 in parse2(ParseTokens, Answer))
385 {
386 yield return false;
387 }
388 }
389 }
390 }
391 }
392
393 public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax)
394 {
395 {
396 Variable Tokens = new Variable();
397 Variable ParseTokens = new Variable();
398 foreach (bool l2 in read_tokens2(Tokens, Variables))
399 {
400 foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
401 {
402 foreach (bool l4 in parse2(ParseTokens, Answer))
403 {
404 yield return false;
405 }
406 }
407 }
408 }
409 }
410
411 public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3)
412 {
413 {
414 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
415 {
416 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
417 {
418 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
419 {
420 yield return false;
421 }
422 }
423 }
424 }
425 {
426 object Ys = arg2;
427 Variable S = new Variable();
428 Variable E = new Variable();
429 Variable Xs = new Variable();
430 Variable Zs = new Variable();
431 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs)))
432 {
433 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs)))
434 {
435 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
436 {
437 yield return false;
438 }
439 yield break;
440 }
441 }
442 }
443 {
444 Variable Pos = new Variable();
445 Variable Xs = new Variable();
446 Variable Ys = new Variable();
447 Variable Pos2 = new Variable();
448 Variable Zs = new Variable();
449 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs)))
450 {
451 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys)))
452 {
453 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs)))
454 {
455 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
456 {
457 foreach (bool l6 in remove_comments(Xs, Ys, Zs))
458 {
459 yield return false;
460 }
461 }
462 yield break;
463 }
464 }
465 }
466 }
467 {
468 Variable Pos = new Variable();
469 Variable Xs = new Variable();
470 Variable Ys = new Variable();
471 Variable Pos2 = new Variable();
472 Variable Zs = new Variable();
473 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs)))
474 {
475 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys)))
476 {
477 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs)))
478 {
479 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
480 {
481 foreach (bool l6 in remove_comments(Xs, Ys, Zs))
482 {
483 yield return false;
484 }
485 }
486 yield break;
487 }
488 }
489 }
490 }
491 {
492 object Zs = arg3;
493 Variable Token = new Variable();
494 Variable Xs = new Variable();
495 Variable Ys = new Variable();
496 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs)))
497 {
498 foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys)))
499 {
500 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
501 {
502 yield return false;
503 }
504 }
505 }
506 }
507 }
508
509 public static IEnumerable<bool> expect(object Token, object arg2, object arg3)
510 {
511 {
512 object Rest = arg3;
513 foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest)))
514 {
515 yield return true;
516 yield break;
517 }
518 }
519 {
520 object S0 = arg2;
521 object x3 = arg3;
522 foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"or"), new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), Atom.NIL)))), S0))
523 {
524 yield return false;
525 }
526 }
527 }
528
529 public static IEnumerable<bool> parse2(object Tokens, object Answer)
530 {
531 {
532 Variable Term = new Variable();
533 Variable LeftOver = new Variable();
534 foreach (bool l2 in clear_errors())
535 {
536 foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver))
537 {
538 foreach (bool l4 in all_read(LeftOver))
539 {
540 foreach (bool l5 in YP.unify(Answer, Term))
541 {
542 yield return false;
543 }
544 yield break;
545 }
546 }
547 foreach (bool l3 in syntax_error(Tokens))
548 {
549 yield return false;
550 }
551 }
552 }
553 }
554
555 public static IEnumerable<bool> all_read(object arg1)
556 {
557 {
558 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
559 {
560 yield return false;
561 }
562 }
563 {
564 Variable Token = new Variable();
565 Variable S = new Variable();
566 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
567 {
568 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"after"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(Token, S)))
569 {
570 yield return false;
571 }
572 }
573 }
574 }
575
576 public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4)
577 {
578 {
579 object x1 = arg2;
580 object x2 = arg3;
581 object x3 = arg4;
582 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
583 {
584 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL))
585 {
586 yield return false;
587 }
588 }
589 }
590 {
591 object Precedence = arg2;
592 object Term = arg3;
593 object LeftOver = arg4;
594 Variable Token = new Variable();
595 Variable RestTokens = new Variable();
596 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens)))
597 {
598 foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver))
599 {
600 yield return false;
601 }
602 }
603 }
604 }
605
606 public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5)
607 {
608 {
609 object S0 = arg2;
610 object x2 = arg3;
611 object x3 = arg4;
612 object x4 = arg5;
613 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
614 {
615 foreach (bool l3 in cannot_start(Atom.a(@"}"), S0))
616 {
617 yield return false;
618 }
619 }
620 }
621 {
622 object S0 = arg2;
623 object x2 = arg3;
624 object x3 = arg4;
625 object x4 = arg5;
626 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
627 {
628 foreach (bool l3 in cannot_start(Atom.a(@"]"), S0))
629 {
630 yield return false;
631 }
632 }
633 }
634 {
635 object S0 = arg2;
636 object x2 = arg3;
637 object x3 = arg4;
638 object x4 = arg5;
639 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
640 {
641 foreach (bool l3 in cannot_start(Atom.a(@")"), S0))
642 {
643 yield return false;
644 }
645 }
646 }
647 {
648 object S0 = arg2;
649 object x2 = arg3;
650 object x3 = arg4;
651 object x4 = arg5;
652 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
653 {
654 foreach (bool l3 in cannot_start(Atom.a(@","), S0))
655 {
656 yield return false;
657 }
658 }
659 }
660 {
661 object S0 = arg2;
662 object x2 = arg3;
663 object x3 = arg4;
664 object x4 = arg5;
665 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
666 {
667 foreach (bool l3 in cannot_start(Atom.a(@"|"), S0))
668 {
669 yield return false;
670 }
671 }
672 }
673 {
674 object S0 = arg2;
675 object Precedence = arg3;
676 object Answer = arg4;
677 object S = arg5;
678 Variable Chars = new Variable();
679 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars)))
680 {
681 foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S))
682 {
683 yield return false;
684 }
685 }
686 }
687 {
688 object S0 = arg2;
689 object Precedence = arg3;
690 object Answer = arg4;
691 object S = arg5;
692 Variable Number = new Variable();
693 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number)))
694 {
695 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
696 {
697 yield return false;
698 }
699 }
700 }
701 {
702 object Precedence = arg3;
703 object Answer = arg4;
704 object S = arg5;
705 Variable S1 = new Variable();
706 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
707 {
708 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1)))
709 {
710 foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S))
711 {
712 yield return false;
713 }
714 yield break;
715 }
716 }
717 }
718 {
719 object S1 = arg2;
720 object Precedence = arg3;
721 object Answer = arg4;
722 object S = arg5;
723 Variable Arg1 = new Variable();
724 Variable S2 = new Variable();
725 Variable RestArgs = new Variable();
726 Variable S3 = new Variable();
727 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
728 {
729 foreach (bool l3 in parse(S1, 999, Arg1, S2))
730 {
731 foreach (bool l4 in read_list(S2, RestArgs, S3))
732 {
733 foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S))
734 {
735 yield return false;
736 }
737 yield break;
738 }
739 }
740 }
741 }
742 {
743 object S1 = arg2;
744 object Precedence = arg3;
745 object Answer = arg4;
746 object S = arg5;
747 Variable Term = new Variable();
748 Variable S2 = new Variable();
749 Variable S3 = new Variable();
750 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
751 {
752 foreach (bool l3 in parse(S1, 1200, Term, S2))
753 {
754 foreach (bool l4 in expect(Atom.a(@")"), S2, S3))
755 {
756 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
757 {
758 yield return false;
759 }
760 yield break;
761 }
762 }
763 }
764 }
765 {
766 object S1 = arg2;
767 object Precedence = arg3;
768 object Answer = arg4;
769 object S = arg5;
770 Variable Term = new Variable();
771 Variable S2 = new Variable();
772 Variable S3 = new Variable();
773 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
774 {
775 foreach (bool l3 in parse(S1, 1200, Term, S2))
776 {
777 foreach (bool l4 in expect(Atom.a(@")"), S2, S3))
778 {
779 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
780 {
781 yield return false;
782 }
783 yield break;
784 }
785 }
786 }
787 }
788 {
789 object Precedence = arg3;
790 object Answer = arg4;
791 object S = arg5;
792 Variable _Pos = new Variable();
793 Variable S1 = new Variable();
794 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos)))
795 {
796 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1)))
797 {
798 foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S))
799 {
800 yield return false;
801 }
802 yield break;
803 }
804 }
805 }
806 {
807 object S1 = arg2;
808 object Precedence = arg3;
809 object Answer = arg4;
810 object S = arg5;
811 Variable Pos = new Variable();
812 Variable Term = new Variable();
813 Variable S2 = new Variable();
814 Variable S3 = new Variable();
815 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos)))
816 {
817 foreach (bool l3 in parse(S1, 1200, Term, S2))
818 {
819 foreach (bool l4 in expect(Atom.a(@"}"), S2, S3))
820 {
821 foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S))
822 {
823 yield return false;
824 }
825 yield break;
826 }
827 }
828 }
829 }
830 {
831 object Precedence = arg3;
832 object Answer = arg4;
833 object S = arg5;
834 Variable Variable_1 = new Variable();
835 Variable Name = new Variable();
836 Variable Pos = new Variable();
837 Variable S1 = new Variable();
838 Variable Arg1 = new Variable();
839 Variable S2 = new Variable();
840 Variable RestArgs = new Variable();
841 Variable S3 = new Variable();
842 Variable Term = new Variable();
843 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos)))
844 {
845 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1)))
846 {
847 foreach (bool l4 in parse(S1, 999, Arg1, S2))
848 {
849 foreach (bool l5 in read_args(S2, RestArgs, S3))
850 {
851 foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a(@"call"), new ListPair(new Functor3(@"$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs)))))
852 {
853 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
854 {
855 yield return false;
856 }
857 }
858 yield break;
859 }
860 }
861 yield break;
862 }
863 }
864 }
865 {
866 object S0 = arg2;
867 object Precedence = arg3;
868 object Answer = arg4;
869 object S = arg5;
870 Variable Variable_1 = new Variable();
871 Variable Name = new Variable();
872 Variable Pos = new Variable();
873 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos)))
874 {
875 foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
876 {
877 yield return false;
878 }
879 }
880 }
881 {
882 object S0 = arg2;
883 object Precedence = arg3;
884 object Answer = arg4;
885 object S = arg5;
886 Variable Atom_1 = new Variable();
887 Variable P = new Variable();
888 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P)))
889 {
890 foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S))
891 {
892 yield return false;
893 }
894 }
895 }
896 }
897
898 public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S)
899 {
900 {
901 Variable _Pos = new Variable();
902 Variable Number = new Variable();
903 Variable S1 = new Variable();
904 Variable Negative = new Variable();
905 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos)))
906 {
907 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1)))
908 {
909 foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
910 {
911 foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S))
912 {
913 yield return false;
914 }
915 }
916 yield break;
917 }
918 }
919 }
920 {
921 Variable Functor_1 = new Variable();
922 Variable Pos = new Variable();
923 Variable S1 = new Variable();
924 Variable Arg1 = new Variable();
925 Variable S2 = new Variable();
926 Variable RestArgs = new Variable();
927 Variable S3 = new Variable();
928 Variable Term = new Variable();
929 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos)))
930 {
931 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1)))
932 {
933 foreach (bool l4 in parse(S1, 999, Arg1, S2))
934 {
935 foreach (bool l5 in read_args(S2, RestArgs, S3))
936 {
937 foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs)))))
938 {
939 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
940 {
941 yield return false;
942 }
943 }
944 yield break;
945 }
946 }
947 yield break;
948 }
949 }
950 }
951 {
952 object S0 = arg2;
953 Variable Op = new Variable();
954 Variable Pos = new Variable();
955 Variable Oprec = new Variable();
956 Variable Aprec = new Variable();
957 Variable Flag = new Variable();
958 Variable Term = new Variable();
959 Variable Arg = new Variable();
960 Variable S1 = new Variable();
961 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos)))
962 {
963 foreach (bool l3 in prefixop(Op, Oprec, Aprec))
964 {
965 foreach (bool l4 in possible_right_operand(S0, Flag))
966 {
967 if (YP.lessThan(Flag, 0))
968 {
969 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL))))
970 {
971 foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S))
972 {
973 yield return false;
974 }
975 }
976 goto cutIf1;
977 }
978 if (YP.greaterThan(Oprec, Precedence))
979 {
980 foreach (bool l6 in syntax_error(new ListPair(Atom.a(@"prefix"), new ListPair(Atom.a(@"operator"), new ListPair(Op, new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"context"), new ListPair(Atom.a(@"with"), new ListPair(Atom.a(@"precedence"), new ListPair(Precedence, Atom.NIL)))))))), S0))
981 {
982 yield return false;
983 }
984 goto cutIf2;
985 }
986 if (YP.greaterThan(Flag, 0))
987 {
988 foreach (bool l6 in parse(S0, Aprec, Arg, S1))
989 {
990 foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL)))))
991 {
992 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
993 {
994 yield return false;
995 }
996 }
997 yield break;
998 }
999 goto cutIf3;
1000 }
1001 foreach (bool l5 in peepop(S0, S1))
1002 {
1003 foreach (bool l6 in prefix_is_atom(S1, Oprec))
1004 {
1005 foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S))
1006 {
1007 yield return false;
1008 }
1009 }
1010 }
1011 foreach (bool l5 in parse(S0, Aprec, Arg, S1))
1012 {
1013 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL)))))
1014 {
1015 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1016 {
1017 yield return false;
1018 }
1019 }
1020 yield break;
1021 }
1022 cutIf3:
1023 cutIf2:
1024 cutIf1:
1025 { }
1026 }
1027 yield break;
1028 }
1029 }
1030 }
1031 {
1032 object S0 = arg2;
1033 Variable Atom_1 = new Variable();
1034 Variable Pos = new Variable();
1035 Variable Term = new Variable();
1036 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos)))
1037 {
1038 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
1039 {
1040 foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
1041 {
1042 yield return false;
1043 }
1044 }
1045 }
1046 }
1047 }
1048
1049 public static IEnumerable<bool> cannot_start(object Token, object S0)
1050 {
1051 {
1052 foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"cannot"), new ListPair(Atom.a(@"start"), new ListPair(Atom.a(@"an"), new ListPair(Atom.a(@"expression"), Atom.NIL))))), S0))
1053 {
1054 yield return false;
1055 }
1056 }
1057 }
1058
1059 public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3)
1060 {
1061 {
1062 object S = arg3;
1063 Variable S1 = new Variable();
1064 Variable Term = new Variable();
1065 Variable Rest = new Variable();
1066 Variable S2 = new Variable();
1067 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1)))
1068 {
1069 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
1070 {
1071 foreach (bool l4 in parse(S1, 999, Term, S2))
1072 {
1073 foreach (bool l5 in read_args(S2, Rest, S))
1074 {
1075 yield return false;
1076 }
1077 yield break;
1078 }
1079 yield break;
1080 }
1081 }
1082 }
1083 {
1084 object S = arg3;
1085 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S)))
1086 {
1087 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1088 {
1089 yield return true;
1090 yield break;
1091 }
1092 }
1093 }
1094 {
1095 object S = arg1;
1096 object x2 = arg2;
1097 object x3 = arg3;
1098 foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", or )"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"arguments"), Atom.NIL)))), S))
1099 {
1100 yield return false;
1101 }
1102 }
1103 }
1104
1105 public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3)
1106 {
1107 {
1108 object x1 = arg2;
1109 object x2 = arg3;
1110 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1111 {
1112 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), Atom.NIL))
1113 {
1114 yield return false;
1115 }
1116 }
1117 }
1118 {
1119 object Rest = arg2;
1120 object S = arg3;
1121 Variable Token = new Variable();
1122 Variable S1 = new Variable();
1123 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
1124 {
1125 foreach (bool l3 in read_list4(Token, S1, Rest, S))
1126 {
1127 yield return false;
1128 }
1129 }
1130 }
1131 }
1132
1133 public static IEnumerable<bool> read_list4(object arg1, object arg2, object arg3, object arg4)
1134 {
1135 {
1136 object S1 = arg2;
1137 object S = arg4;
1138 Variable Term = new Variable();
1139 Variable Rest = new Variable();
1140 Variable S2 = new Variable();
1141 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1142 {
1143 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest)))
1144 {
1145 foreach (bool l4 in parse(S1, 999, Term, S2))
1146 {
1147 foreach (bool l5 in read_list(S2, Rest, S))
1148 {
1149 yield return false;
1150 }
1151 yield break;
1152 }
1153 yield break;
1154 }
1155 }
1156 }
1157 {
1158 object S1 = arg2;
1159 object Rest = arg3;
1160 object S = arg4;
1161 Variable S2 = new Variable();
1162 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1163 {
1164 foreach (bool l3 in parse(S1, 999, Rest, S2))
1165 {
1166 foreach (bool l4 in expect(Atom.a(@"]"), S2, S))
1167 {
1168 yield return false;
1169 }
1170 yield break;
1171 }
1172 yield break;
1173 }
1174 }
1175 {
1176 Variable S1 = new Variable();
1177 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1178 {
1179 foreach (bool l3 in YP.unify(arg2, S1))
1180 {
1181 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1182 {
1183 foreach (bool l5 in YP.unify(arg4, S1))
1184 {
1185 yield return true;
1186 yield break;
1187 }
1188 }
1189 }
1190 }
1191 }
1192 {
1193 object Token = arg1;
1194 object S1 = arg2;
1195 object x3 = arg3;
1196 object x4 = arg4;
1197 foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), new ListPair(Token, S1)))
1198 {
1199 yield return false;
1200 }
1201 }
1202 }
1203
1204 public static IEnumerable<bool> possible_right_operand(object arg1, object arg2)
1205 {
1206 {
1207 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1208 {
1209 foreach (bool l3 in YP.unify(arg2, -1))
1210 {
1211 yield return false;
1212 }
1213 }
1214 }
1215 {
1216 object Flag = arg2;
1217 Variable H = new Variable();
1218 Variable T = new Variable();
1219 foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
1220 {
1221 foreach (bool l3 in possible_right_operand3(H, Flag, T))
1222 {
1223 yield return false;
1224 }
1225 }
1226 }
1227 }
1228
1229 public static IEnumerable<bool> possible_right_operand3(object arg1, object arg2, object arg3)
1230 {
1231 {
1232 object x4 = arg3;
1233 Variable x1 = new Variable();
1234 Variable x2 = new Variable();
1235 Variable x3 = new Variable();
1236 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3)))
1237 {
1238 foreach (bool l3 in YP.unify(arg2, 1))
1239 {
1240 yield return false;
1241 }
1242 }
1243 }
1244 {
1245 object x2 = arg3;
1246 Variable x1 = new Variable();
1247 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1)))
1248 {
1249 foreach (bool l3 in YP.unify(arg2, 1))
1250 {
1251 yield return false;
1252 }
1253 }
1254 }
1255 {
1256 object x2 = arg3;
1257 Variable x1 = new Variable();
1258 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1)))
1259 {
1260 foreach (bool l3 in YP.unify(arg2, 1))
1261 {
1262 yield return false;
1263 }
1264 }
1265 }
1266 {
1267 object x1 = arg3;
1268 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
1269 {
1270 foreach (bool l3 in YP.unify(arg2, 1))
1271 {
1272 yield return false;
1273 }
1274 }
1275 }
1276 {
1277 object x1 = arg3;
1278 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
1279 {
1280 foreach (bool l3 in YP.unify(arg2, 0))
1281 {
1282 yield return false;
1283 }
1284 }
1285 }
1286 {
1287 object x1 = arg3;
1288 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1289 {
1290 foreach (bool l3 in YP.unify(arg2, -1))
1291 {
1292 yield return false;
1293 }
1294 }
1295 }
1296 {
1297 Variable x1 = new Variable();
1298 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1299 {
1300 foreach (bool l3 in YP.unify(arg2, 0))
1301 {
1302 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1)))
1303 {
1304 yield return true;
1305 yield break;
1306 }
1307 }
1308 }
1309 }
1310 {
1311 object x1 = arg3;
1312 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1313 {
1314 foreach (bool l3 in YP.unify(arg2, 1))
1315 {
1316 yield return false;
1317 }
1318 }
1319 }
1320 {
1321 object x1 = arg3;
1322 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1323 {
1324 foreach (bool l3 in YP.unify(arg2, -1))
1325 {
1326 yield return false;
1327 }
1328 }
1329 }
1330 {
1331 Variable x1 = new Variable();
1332 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1333 {
1334 foreach (bool l3 in YP.unify(arg2, 0))
1335 {
1336 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1)))
1337 {
1338 yield return true;
1339 yield break;
1340 }
1341 }
1342 }
1343 }
1344 {
1345 object x1 = arg3;
1346 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1347 {
1348 foreach (bool l3 in YP.unify(arg2, 1))
1349 {
1350 yield return false;
1351 }
1352 }
1353 }
1354 {
1355 object x1 = arg3;
1356 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1357 {
1358 foreach (bool l3 in YP.unify(arg2, -1))
1359 {
1360 yield return false;
1361 }
1362 }
1363 }
1364 {
1365 object x1 = arg3;
1366 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1367 {
1368 foreach (bool l3 in YP.unify(arg2, -1))
1369 {
1370 yield return false;
1371 }
1372 }
1373 }
1374 {
1375 object x1 = arg3;
1376 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1377 {
1378 foreach (bool l3 in YP.unify(arg2, -1))
1379 {
1380 yield return false;
1381 }
1382 }
1383 }
1384 {
1385 object x3 = arg3;
1386 Variable x1 = new Variable();
1387 Variable x2 = new Variable();
1388 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2)))
1389 {
1390 foreach (bool l3 in YP.unify(arg2, 0))
1391 {
1392 yield return false;
1393 }
1394 }
1395 }
1396 }
1397
1398 public static IEnumerable<bool> peepop(object arg1, object arg2)
1399 {
1400 {
1401 Variable F = new Variable();
1402 Variable Pos = new Variable();
1403 Variable S1 = new Variable();
1404 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1))))
1405 {
1406 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1))))
1407 {
1408 yield return true;
1409 yield break;
1410 }
1411 }
1412 }
1413 {
1414 Variable F = new Variable();
1415 Variable Pos = new Variable();
1416 Variable S1 = new Variable();
1417 Variable L = new Variable();
1418 Variable P = new Variable();
1419 Variable R = new Variable();
1420 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1)))
1421 {
1422 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, P, R }), S1)))
1423 {
1424 foreach (bool l4 in infixop(F, L, P, R))
1425 {
1426 yield return false;
1427 }
1428 }
1429 }
1430 }
1431 {
1432 Variable F = new Variable();
1433 Variable Pos = new Variable();
1434 Variable S1 = new Variable();
1435 Variable L = new Variable();
1436 Variable P = new Variable();
1437 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1)))
1438 {
1439 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1)))
1440 {
1441 foreach (bool l4 in postfixop(F, L, P))
1442 {
1443 yield return false;
1444 }
1445 }
1446 }
1447 }
1448 {
1449 Variable S0 = new Variable();
1450 foreach (bool l2 in YP.unify(arg1, S0))
1451 {
1452 foreach (bool l3 in YP.unify(arg2, S0))
1453 {
1454 yield return false;
1455 }
1456 }
1457 }
1458 }
1459
1460 public static IEnumerable<bool> prefix_is_atom(object arg1, object arg2)
1461 {
1462 {
1463 object Precedence = arg2;
1464 Variable Token = new Variable();
1465 Variable x2 = new Variable();
1466 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, x2)))
1467 {
1468 foreach (bool l3 in prefix_is_atom(Token, Precedence))
1469 {
1470 yield return false;
1471 }
1472 }
1473 }
1474 {
1475 object P = arg2;
1476 Variable x1 = new Variable();
1477 Variable L = new Variable();
1478 Variable x3 = new Variable();
1479 Variable x4 = new Variable();
1480 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 })))
1481 {
1482 if (YP.greaterThanOrEqual(L, P))
1483 {
1484 yield return false;
1485 }
1486 }
1487 }
1488 {
1489 object P = arg2;
1490 Variable x1 = new Variable();
1491 Variable L = new Variable();
1492 Variable x3 = new Variable();
1493 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3)))
1494 {
1495 if (YP.greaterThanOrEqual(L, P))
1496 {
1497 yield return false;
1498 }
1499 }
1500 }
1501 {
1502 object x1 = arg2;
1503 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1504 {
1505 yield return false;
1506 }
1507 }
1508 {
1509 object x1 = arg2;
1510 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1511 {
1512 yield return false;
1513 }
1514 }
1515 {
1516 object x1 = arg2;
1517 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1518 {
1519 yield return false;
1520 }
1521 }
1522 {
1523 object P = arg2;
1524 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1525 {
1526 if (YP.greaterThanOrEqual(1100, P))
1527 {
1528 yield return false;
1529 }
1530 }
1531 }
1532 {
1533 object P = arg2;
1534 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1535 {
1536 if (YP.greaterThanOrEqual(1000, P))
1537 {
1538 yield return false;
1539 }
1540 }
1541 }
1542 {
1543 object x1 = arg2;
1544 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1545 {
1546 yield return false;
1547 }
1548 }
1549 }
1550
1551 public static IEnumerable<bool> exprtl0(object arg1, object arg2, object arg3, object arg4, object arg5)
1552 {
1553 {
1554 object x2 = arg3;
1555 Variable Term = new Variable();
1556 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1557 {
1558 foreach (bool l3 in YP.unify(arg2, Term))
1559 {
1560 foreach (bool l4 in YP.unify(arg4, Term))
1561 {
1562 foreach (bool l5 in YP.unify(arg5, Atom.NIL))
1563 {
1564 yield return false;
1565 }
1566 }
1567 }
1568 }
1569 }
1570 {
1571 object Term = arg2;
1572 object Precedence = arg3;
1573 object Answer = arg4;
1574 object S = arg5;
1575 Variable Token = new Variable();
1576 Variable S1 = new Variable();
1577 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
1578 {
1579 foreach (bool l3 in exprtl0_6(Token, Term, Precedence, Answer, S, S1))
1580 {
1581 yield return false;
1582 }
1583 }
1584 }
1585 }
1586
1587 public static IEnumerable<bool> exprtl0_6(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1588 {
1589 {
1590 object x2 = arg3;
1591 object S1 = arg6;
1592 Variable Term = new Variable();
1593 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}")))
1594 {
1595 foreach (bool l3 in YP.unify(arg2, Term))
1596 {
1597 foreach (bool l4 in YP.unify(arg4, Term))
1598 {
1599 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1)))
1600 {
1601 yield return false;
1602 }
1603 }
1604 }
1605 }
1606 }
1607 {
1608 object x2 = arg3;
1609 object S1 = arg6;
1610 Variable Term = new Variable();
1611 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]")))
1612 {
1613 foreach (bool l3 in YP.unify(arg2, Term))
1614 {
1615 foreach (bool l4 in YP.unify(arg4, Term))
1616 {
1617 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1)))
1618 {
1619 yield return false;
1620 }
1621 }
1622 }
1623 }
1624 }
1625 {
1626 object x2 = arg3;
1627 object S1 = arg6;
1628 Variable Term = new Variable();
1629 foreach (bool l2 in YP.unify(arg1, Atom.a(@")")))
1630 {
1631 foreach (bool l3 in YP.unify(arg2, Term))
1632 {
1633 foreach (bool l4 in YP.unify(arg4, Term))
1634 {
1635 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1)))
1636 {
1637 yield return false;
1638 }
1639 }
1640 }
1641 }
1642 }
1643 {
1644 object Term = arg2;
1645 object Precedence = arg3;
1646 object Answer = arg4;
1647 object S = arg5;
1648 object S1 = arg6;
1649 Variable Next = new Variable();
1650 Variable S2 = new Variable();
1651 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
1652 {
1653 if (YP.greaterThanOrEqual(Precedence, 1000))
1654 {
1655 foreach (bool l4 in parse(S1, 1000, Next, S2))
1656 {
1657 foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S))
1658 {
1659 yield return false;
1660 }
1661 yield break;
1662 }
1663 goto cutIf1;
1664 }
1665 foreach (bool l3 in YP.unify(Answer, Term))
1666 {
1667 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1)))
1668 {
1669 yield return false;
1670 }
1671 }
1672 cutIf1:
1673 { }
1674 }
1675 }
1676 {
1677 object Term = arg2;
1678 object Precedence = arg3;
1679 object Answer = arg4;
1680 object S = arg5;
1681 object S1 = arg6;
1682 Variable Next = new Variable();
1683 Variable S2 = new Variable();
1684 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
1685 {
1686 if (YP.greaterThanOrEqual(Precedence, 1100))
1687 {
1688 foreach (bool l4 in parse(S1, 1100, Next, S2))
1689 {
1690 foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S))
1691 {
1692 yield return false;
1693 }
1694 yield break;
1695 }
1696 goto cutIf2;
1697 }
1698 foreach (bool l3 in YP.unify(Answer, Term))
1699 {
1700 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1)))
1701 {
1702 yield return false;
1703 }
1704 }
1705 cutIf2:
1706 { }
1707 }
1708 }
1709 {
1710 object x2 = arg2;
1711 object x3 = arg3;
1712 object x4 = arg4;
1713 object x5 = arg5;
1714 object S1 = arg6;
1715 Variable S = new Variable();
1716 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S)))
1717 {
1718 foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1))
1719 {
1720 yield return false;
1721 }
1722 }
1723 }
1724 {
1725 object x2 = arg2;
1726 object x3 = arg3;
1727 object x4 = arg4;
1728 object x5 = arg5;
1729 object S1 = arg6;
1730 Variable N = new Variable();
1731 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N)))
1732 {
1733 foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1))
1734 {
1735 yield return false;
1736 }
1737 }
1738 }
1739 {
1740 object Term = arg2;
1741 object Precedence = arg3;
1742 object Answer = arg4;
1743 object S = arg5;
1744 Variable S1 = new Variable();
1745 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1746 {
1747 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1)))
1748 {
1749 foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1))
1750 {
1751 yield return false;
1752 }
1753 yield break;
1754 }
1755 }
1756 }
1757 {
1758 object x1 = arg2;
1759 object x2 = arg3;
1760 object x3 = arg4;
1761 object x4 = arg5;
1762 object S1 = arg6;
1763 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{")))
1764 {
1765 foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1))
1766 {
1767 yield return false;
1768 }
1769 }
1770 }
1771 {
1772 object Term = arg2;
1773 object Precedence = arg3;
1774 object Answer = arg4;
1775 object S = arg5;
1776 Variable S1 = new Variable();
1777 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1778 {
1779 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1)))
1780 {
1781 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1))
1782 {
1783 yield return false;
1784 }
1785 yield break;
1786 }
1787 }
1788 }
1789 {
1790 object x1 = arg2;
1791 object x2 = arg3;
1792 object x3 = arg4;
1793 object x4 = arg5;
1794 object S1 = arg6;
1795 foreach (bool l2 in YP.unify(arg1, Atom.a(@"[")))
1796 {
1797 foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1))
1798 {
1799 yield return false;
1800 }
1801 }
1802 }
1803 {
1804 object x1 = arg2;
1805 object x2 = arg3;
1806 object x3 = arg4;
1807 object x4 = arg5;
1808 object S1 = arg6;
1809 foreach (bool l2 in YP.unify(arg1, Atom.a(@"(")))
1810 {
1811 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1))
1812 {
1813 yield return false;
1814 }
1815 }
1816 }
1817 {
1818 object x1 = arg2;
1819 object x2 = arg3;
1820 object x3 = arg4;
1821 object x4 = arg5;
1822 object S1 = arg6;
1823 foreach (bool l2 in YP.unify(arg1, Atom.a(@" (")))
1824 {
1825 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1))
1826 {
1827 yield return false;
1828 }
1829 }
1830 }
1831 {
1832 object x4 = arg2;
1833 object x5 = arg3;
1834 object x6 = arg4;
1835 object x7 = arg5;
1836 object S1 = arg6;
1837 Variable A = new Variable();
1838 Variable B = new Variable();
1839 Variable P = new Variable();
1840 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P)))
1841 {
1842 foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1))
1843 {
1844 yield return false;
1845 }
1846 }
1847 }
1848 {
1849 object Term = arg2;
1850 object Precedence = arg3;
1851 object Answer = arg4;
1852 object S = arg5;
1853 object S1 = arg6;
1854 Variable F = new Variable();
1855 Variable P = new Variable();
1856 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P)))
1857 {
1858 foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1))
1859 {
1860 yield return false;
1861 }
1862 }
1863 }
1864 }
1865
1866 public static IEnumerable<bool> exprtl0_atom(object arg1, object arg2, object arg3, object arg4, object arg5, object S1)
1867 {
1868 {
1869 object Term = arg2;
1870 object Precedence = arg3;
1871 object Answer = arg4;
1872 object S = arg5;
1873 Variable F = new Variable();
1874 Variable Pos = new Variable();
1875 Variable L1 = new Variable();
1876 Variable O1 = new Variable();
1877 Variable R1 = new Variable();
1878 Variable L2 = new Variable();
1879 Variable O2 = new Variable();
1880 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1881 {
1882 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2))
1883 {
1884 foreach (bool l4 in prefix_is_atom(S1, Precedence))
1885 {
1886 foreach (bool l5 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1887 {
1888 yield return false;
1889 }
1890 yield break;
1891 }
1892 foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S))
1893 {
1894 yield return false;
1895 }
1896 foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1897 {
1898 yield return false;
1899 }
1900 yield break;
1901 }
1902 }
1903 }
1904 {
1905 object Term = arg2;
1906 object Precedence = arg3;
1907 object Answer = arg4;
1908 object S = arg5;
1909 Variable F = new Variable();
1910 Variable Pos = new Variable();
1911 Variable L1 = new Variable();
1912 Variable O1 = new Variable();
1913 Variable R1 = new Variable();
1914 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1915 {
1916 foreach (bool l3 in infixop(F, L1, O1, R1))
1917 {
1918 foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S))
1919 {
1920 yield return false;
1921 }
1922 yield break;
1923 }
1924 }
1925 }
1926 {
1927 object Term = arg2;
1928 object Precedence = arg3;
1929 object Answer = arg4;
1930 object S = arg5;
1931 Variable F = new Variable();
1932 Variable Pos = new Variable();
1933 Variable L2 = new Variable();
1934 Variable O2 = new Variable();
1935 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos)))
1936 {
1937 foreach (bool l3 in postfixop(F, L2, O2))
1938 {
1939 foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S))
1940 {
1941 yield return false;
1942 }
1943 yield break;
1944 }
1945 }
1946 }
1947 {
1948 object X = arg1;
1949 object x2 = arg2;
1950 object x3 = arg3;
1951 object x4 = arg4;
1952 object x5 = arg5;
1953 Variable x7 = new Variable();
1954 foreach (bool l2 in syntax_error(new ListPair(new Functor2(@"-", Atom.a(@"non"), Atom.a(@"operator")), new ListPair(X, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(new Functor2(@"atom", X, x7), S1)))
1955 {
1956 yield return false;
1957 }
1958 yield break;
1959 }
1960 }
1961
1962 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens)
1963 {
1964 {
1965 foreach (bool l2 in syntax_error(new ListPair(Type, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL))), new ListPair(Token, Tokens)))
1966 {
1967 yield return false;
1968 }
1969 }
1970 }
1971
1972 public static IEnumerable<bool> exprtl(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1973 {
1974 {
1975 object x1 = arg2;
1976 object x3 = arg4;
1977 Variable Term = new Variable();
1978 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1979 {
1980 foreach (bool l3 in YP.unify(arg3, Term))
1981 {
1982 foreach (bool l4 in YP.unify(arg5, Term))
1983 {
1984 foreach (bool l5 in YP.unify(arg6, Atom.NIL))
1985 {
1986 yield return false;
1987 }
1988 }
1989 }
1990 }
1991 }
1992 {
1993 object C = arg2;
1994 object Term = arg3;
1995 object Precedence = arg4;
1996 object Answer = arg5;
1997 object S = arg6;
1998 Variable Token = new Variable();
1999 Variable Tokens = new Variable();
2000 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Tokens)))
2001 {
2002 foreach (bool l3 in exprtl_7(Token, C, Term, Precedence, Answer, S, Tokens))
2003 {
2004 yield return false;
2005 }
2006 }
2007 }
2008 }
2009
2010 public static IEnumerable<bool> exprtl_7(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7)
2011 {
2012 {
2013 object C = arg2;
2014 object Term = arg3;
2015 object Precedence = arg4;
2016 object Answer = arg5;
2017 object S = arg6;
2018 object S1 = arg7;
2019 Variable F = new Variable();
2020 Variable Pos = new Variable();
2021 Variable L = new Variable();
2022 Variable O = new Variable();
2023 Variable R = new Variable();
2024 Variable Other = new Variable();
2025 Variable S2 = new Variable();
2026 Variable Expr = new Variable();
2027 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R })))
2028 {
2029 if (YP.greaterThanOrEqual(Precedence, O))
2030 {
2031 if (YP.lessThanOrEqual(C, L))
2032 {
2033 foreach (bool l5 in parse(S1, R, Other, S2))
2034 {
2035 foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL))))))
2036 {
2037 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2038 {
2039 yield return false;
2040 }
2041 }
2042 }
2043 yield break;
2044 }
2045 }
2046 }
2047 }
2048 {
2049 object C = arg2;
2050 object Term = arg3;
2051 object Precedence = arg4;
2052 object Answer = arg5;
2053 object S = arg6;
2054 object S1 = arg7;
2055 Variable F = new Variable();
2056 Variable Pos = new Variable();
2057 Variable L = new Variable();
2058 Variable O = new Variable();
2059 Variable Expr = new Variable();
2060 Variable S2 = new Variable();
2061 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O)))
2062 {
2063 if (YP.greaterThanOrEqual(Precedence, O))
2064 {
2065 if (YP.lessThanOrEqual(C, L))
2066 {
2067 foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL)))))
2068 {
2069 foreach (bool l6 in peepop(S1, S2))
2070 {
2071 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2072 {
2073 yield return false;
2074 }
2075 }
2076 }
2077 yield break;
2078 }
2079 }
2080 }
2081 }
2082 {
2083 object C = arg2;
2084 object Term = arg3;
2085 object Precedence = arg4;
2086 object Answer = arg5;
2087 object S = arg6;
2088 object S1 = arg7;
2089 Variable Next = new Variable();
2090 Variable S2 = new Variable();
2091 foreach (bool l2 in YP.unify(arg1, Atom.a(@",")))
2092 {
2093 if (YP.greaterThanOrEqual(Precedence, 1000))
2094 {
2095 if (YP.lessThan(C, 1000))
2096 {
2097 foreach (bool l5 in parse(S1, 1000, Next, S2))
2098 {
2099 foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S))
2100 {
2101 yield return false;
2102 }
2103 }
2104 yield break;
2105 }
2106 }
2107 }
2108 }
2109 {
2110 object C = arg2;
2111 object Term = arg3;
2112 object Precedence = arg4;
2113 object Answer = arg5;
2114 object S = arg6;
2115 object S1 = arg7;
2116 Variable Next = new Variable();
2117 Variable S2 = new Variable();
2118 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|")))
2119 {
2120 if (YP.greaterThanOrEqual(Precedence, 1100))
2121 {
2122 if (YP.lessThan(C, 1100))
2123 {
2124 foreach (bool l5 in parse(S1, 1100, Next, S2))
2125 {
2126 foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S))
2127 {
2128 yield return false;
2129 }
2130 }
2131 yield break;
2132 }
2133 }
2134 }
2135 }
2136 {
2137 object Token = arg1;
2138 object x2 = arg2;
2139 object x4 = arg4;
2140 object Tokens = arg7;
2141 Variable Term = new Variable();
2142 foreach (bool l2 in YP.unify(arg3, Term))
2143 {
2144 foreach (bool l3 in YP.unify(arg5, Term))
2145 {
2146 foreach (bool l4 in YP.unify(arg6, new ListPair(Token, Tokens)))
2147 {
2148 yield return false;
2149 }
2150 }
2151 }
2152 }
2153 }
2154
2155 public static IEnumerable<bool> syntax_error(object _Message, object _List)
2156 {
2157 {
2158 yield break;
2159 }
2160 }
2161
2162 public static IEnumerable<bool> syntax_error(object _List)
2163 {
2164 {
2165 yield break;
2166 }
2167 }
2168
2169 public static IEnumerable<bool> prefixop(object F, object O, object Q)
2170 {
2171 {
2172 foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F))
2173 {
2174 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2175 {
2176 yield return false;
2177 }
2178 goto cutIf1;
2179 }
2180 foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F))
2181 {
2182 foreach (bool l3 in YP.unify(Q, O))
2183 {
2184 yield return false;
2185 }
2186 goto cutIf2;
2187 }
2188 cutIf2:
2189 cutIf1:
2190 { }
2191 }
2192 }
2193
2194 public static IEnumerable<bool> postfixop(object F, object P, object O)
2195 {
2196 {
2197 foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F))
2198 {
2199 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2200 {
2201 yield return false;
2202 }
2203 goto cutIf1;
2204 }
2205 foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F))
2206 {
2207 foreach (bool l3 in YP.unify(P, O))
2208 {
2209 yield return false;
2210 }
2211 goto cutIf2;
2212 }
2213 cutIf2:
2214 cutIf1:
2215 { }
2216 }
2217 }
2218
2219 public static IEnumerable<bool> infixop(object F, object P, object O, object Q)
2220 {
2221 {
2222 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F))
2223 {
2224 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2225 {
2226 foreach (bool l4 in YP.unify(Q, O))
2227 {
2228 yield return false;
2229 }
2230 }
2231 goto cutIf1;
2232 }
2233 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F))
2234 {
2235 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2236 {
2237 foreach (bool l4 in YP.unify(Q, P))
2238 {
2239 yield return false;
2240 }
2241 }
2242 goto cutIf2;
2243 }
2244 foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F))
2245 {
2246 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2247 {
2248 foreach (bool l4 in YP.unify(P, O))
2249 {
2250 yield return false;
2251 }
2252 }
2253 goto cutIf3;
2254 }
2255 cutIf3:
2256 cutIf2:
2257 cutIf1:
2258 { }
2259 }
2260 }
2261
2262 public static IEnumerable<bool> ambigop(object F, object Precedence, object L1, object O1, object R1, object L2, object O2)
2263 {
2264 {
2265 foreach (bool l2 in postfixop(F, L2, O2))
2266 {
2267 if (YP.lessThanOrEqual(O2, Precedence))
2268 {
2269 foreach (bool l4 in infixop(F, L1, O1, R1))
2270 {
2271 if (YP.lessThanOrEqual(O1, Precedence))
2272 {
2273 yield return false;
2274 }
2275 }
2276 }
2277 }
2278 }
2279 }
2280
2281 public static IEnumerable<bool> read_tokens1(object arg1)
2282 {
2283 {
2284 object TokenList = arg1;
2285 Variable C1 = new Variable();
2286 Variable _X = new Variable();
2287 Variable ListOfTokens = new Variable();
2288 foreach (bool l2 in YP.get_code(C1))
2289 {
2290 foreach (bool l3 in read_tokens(C1, _X, ListOfTokens))
2291 {
2292 foreach (bool l4 in YP.unify(TokenList, ListOfTokens))
2293 {
2294 yield return false;
2295 }
2296 yield break;
2297 }
2298 }
2299 }
2300 {
2301 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL)))
2302 {
2303 yield return false;
2304 }
2305 }
2306 }
2307
2308 public static IEnumerable<bool> read_tokens2(object arg1, object arg2)
2309 {
2310 {
2311 object TokenList = arg1;
2312 object Dictionary = arg2;
2313 Variable C1 = new Variable();
2314 Variable Dict = new Variable();
2315 Variable ListOfTokens = new Variable();
2316 foreach (bool l2 in YP.get_code(C1))
2317 {
2318 foreach (bool l3 in read_tokens(C1, Dict, ListOfTokens))
2319 {
2320 foreach (bool l4 in terminate_list(Dict))
2321 {
2322 foreach (bool l5 in YP.unify(Dictionary, Dict))
2323 {
2324 foreach (bool l6 in YP.unify(TokenList, ListOfTokens))
2325 {
2326 yield return false;
2327 }
2328 }
2329 yield break;
2330 }
2331 }
2332 }
2333 }
2334 {
2335 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL)))
2336 {
2337 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2338 {
2339 yield return false;
2340 }
2341 }
2342 }
2343 }
2344
2345 public static IEnumerable<bool> terminate_list(object arg1)
2346 {
2347 {
2348 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
2349 {
2350 yield return false;
2351 }
2352 }
2353 {
2354 Variable x1 = new Variable();
2355 Variable Tail = new Variable();
2356 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Tail)))
2357 {
2358 foreach (bool l3 in terminate_list(Tail))
2359 {
2360 yield return false;
2361 }
2362 }
2363 }
2364 }
2365
2366 public static IEnumerable<bool> read_special(object arg1, object Dict, object arg3)
2367 {
2368 {
2369 object Tokens = arg3;
2370 foreach (bool l2 in YP.unify(arg1, 95))
2371 {
2372 foreach (bool l3 in read_variable(95, Dict, Tokens))
2373 {
2374 yield return false;
2375 }
2376 }
2377 }
2378 {
2379 object Tokens = arg3;
2380 foreach (bool l2 in YP.unify(arg1, 247))
2381 {
2382 foreach (bool l3 in read_symbol(247, Dict, Tokens))
2383 {
2384 yield return false;
2385 }
2386 }
2387 }
2388 {
2389 object Tokens = arg3;
2390 foreach (bool l2 in YP.unify(arg1, 215))
2391 {
2392 foreach (bool l3 in read_symbol(215, Dict, Tokens))
2393 {
2394 yield return false;
2395 }
2396 }
2397 }
2398 {
2399 Variable StartPos = new Variable();
2400 Variable EndPos = new Variable();
2401 Variable Tokens = new Variable();
2402 Variable Ch = new Variable();
2403 Variable NextCh = new Variable();
2404 foreach (bool l2 in YP.unify(arg1, 37))
2405 {
2406 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens)))
2407 {
2408 foreach (bool l4 in get_current_position(StartPos))
2409 {
2410 foreach (bool l5 in YP.repeat())
2411 {
2412 foreach (bool l6 in YP.get_code(Ch))
2413 {
2414 if (YP.lessThan(Ch, new ListPair(32, Atom.NIL)))
2415 {
2416 if (YP.notEqual(Ch, 9))
2417 {
2418 if (YP.termNotEqual(Ch, -1))
2419 {
2420 foreach (bool l10 in get_current_position(EndPos))
2421 {
2422 foreach (bool l11 in YP.get_code(NextCh))
2423 {
2424 foreach (bool l12 in read_tokens(NextCh, Dict, Tokens))
2425 {
2426 yield return false;
2427 }
2428 }
2429 }
2430 }
2431 yield break;
2432 }
2433 }
2434 }
2435 }
2436 }
2437 }
2438 }
2439 }
2440 {
2441 object T = arg3;
2442 Variable C2 = new Variable();
2443 Variable StartPos = new Variable();
2444 Variable EndPos = new Variable();
2445 Variable Tokens = new Variable();
2446 Variable StartPos1 = new Variable();
2447 Variable NextCh = new Variable();
2448 Variable Chars = new Variable();
2449 foreach (bool l2 in YP.unify(arg1, 47))
2450 {
2451 foreach (bool l3 in YP.get_code(C2))
2452 {
2453 if (YP.equal(C2, new ListPair(42, Atom.NIL)))
2454 {
2455 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens)))
2456 {
2457 foreach (bool l6 in get_current_position(StartPos1))
2458 {
2459 foreach (bool l7 in YP.unify(StartPos, YP.subtract(StartPos1, 1)))
2460 {
2461 foreach (bool l8 in read_solidus(32, NextCh))
2462 {
2463 foreach (bool l9 in get_current_position(EndPos))
2464 {
2465 foreach (bool l10 in read_tokens(NextCh, Dict, Tokens))
2466 {
2467 yield return false;
2468 }
2469 }
2470 }
2471 }
2472 }
2473 }
2474 goto cutIf1;
2475 }
2476 foreach (bool l4 in YP.unify(T, Tokens))
2477 {
2478 foreach (bool l5 in rest_symbol(C2, Chars, NextCh))
2479 {
2480 foreach (bool l6 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(47, Chars)))
2481 {
2482 yield return false;
2483 }
2484 }
2485 }
2486 cutIf1:
2487 { }
2488 }
2489 }
2490 }
2491 {
2492 Variable Pos = new Variable();
2493 Variable Tokens = new Variable();
2494 Variable NextCh = new Variable();
2495 foreach (bool l2 in YP.unify(arg1, 33))
2496 {
2497 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens)))
2498 {
2499 foreach (bool l4 in get_current_position(Pos))
2500 {
2501 foreach (bool l5 in YP.get_code(NextCh))
2502 {
2503 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2504 {
2505 yield return false;
2506 }
2507 }
2508 }
2509 }
2510 }
2511 }
2512 {
2513 Variable Tokens = new Variable();
2514 Variable NextCh = new Variable();
2515 foreach (bool l2 in YP.unify(arg1, 40))
2516 {
2517 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens)))
2518 {
2519 foreach (bool l4 in YP.get_code(NextCh))
2520 {
2521 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2522 {
2523 yield return false;
2524 }
2525 }
2526 }
2527 }
2528 }
2529 {
2530 Variable Tokens = new Variable();
2531 Variable NextCh = new Variable();
2532 foreach (bool l2 in YP.unify(arg1, 41))
2533 {
2534 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@")"), Tokens)))
2535 {
2536 foreach (bool l4 in YP.get_code(NextCh))
2537 {
2538 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2539 {
2540 yield return false;
2541 }
2542 }
2543 }
2544 }
2545 }
2546 {
2547 Variable Tokens = new Variable();
2548 Variable NextCh = new Variable();
2549 foreach (bool l2 in YP.unify(arg1, 44))
2550 {
2551 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@","), Tokens)))
2552 {
2553 foreach (bool l4 in YP.get_code(NextCh))
2554 {
2555 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2556 {
2557 yield return false;
2558 }
2559 }
2560 }
2561 }
2562 }
2563 {
2564 Variable Pos = new Variable();
2565 Variable Tokens = new Variable();
2566 Variable NextCh = new Variable();
2567 foreach (bool l2 in YP.unify(arg1, 59))
2568 {
2569 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens)))
2570 {
2571 foreach (bool l4 in get_current_position(Pos))
2572 {
2573 foreach (bool l5 in YP.get_code(NextCh))
2574 {
2575 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2576 {
2577 yield return false;
2578 }
2579 }
2580 }
2581 }
2582 }
2583 }
2584 {
2585 Variable Pos = new Variable();
2586 Variable Tokens = new Variable();
2587 Variable NextCh = new Variable();
2588 foreach (bool l2 in YP.unify(arg1, 91))
2589 {
2590 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens)))
2591 {
2592 foreach (bool l4 in get_current_position(Pos))
2593 {
2594 foreach (bool l5 in YP.get_code(NextCh))
2595 {
2596 foreach (bool l6 in read_tokens(NextCh, Dict, Tokens))
2597 {
2598 yield return false;
2599 }
2600 }
2601 }
2602 }
2603 }
2604 }
2605 {
2606 Variable Pos = new Variable();
2607 Variable Tokens = new Variable();
2608 Variable NextCh = new Variable();
2609 foreach (bool l2 in YP.unify(arg1, 93))
2610 {
2611 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens)))
2612 {
2613 foreach (bool l4 in get_current_position(Pos))
2614 {
2615 foreach (bool l5 in YP.get_code(NextCh))
2616 {
2617 foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens))
2618 {
2619 yield return false;
2620 }
2621 }
2622 }
2623 }
2624 }
2625 }
2626 {
2627 Variable Pos = new Variable();
2628 Variable Tokens = new Variable();
2629 Variable NextCh = new Variable();
2630 foreach (bool l2 in YP.unify(arg1, 123))
2631 {
2632 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens)))
2633 {
2634 foreach (bool l4 in get_current_position(Pos))
2635 {
2636 foreach (bool l5 in YP.get_code(NextCh))
2637 {
2638 foreach (bool l6 in read_tokens(NextCh, Dict, Tokens))
2639 {
2640 yield return false;
2641 }
2642 }
2643 }
2644 }
2645 }
2646 }
2647 {
2648 Variable Tokens = new Variable();
2649 Variable NextCh = new Variable();
2650 foreach (bool l2 in YP.unify(arg1, 124))
2651 {
2652 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens)))
2653 {
2654 foreach (bool l4 in YP.get_code(NextCh))
2655 {
2656 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2657 {
2658 yield return false;
2659 }
2660 }
2661 }
2662 }
2663 }
2664 {
2665 Variable Tokens = new Variable();
2666 Variable NextCh = new Variable();
2667 foreach (bool l2 in YP.unify(arg1, 125))
2668 {
2669 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens)))
2670 {
2671 foreach (bool l4 in YP.get_code(NextCh))
2672 {
2673 foreach (bool l5 in read_after_atom(NextCh, Dict, Tokens))
2674 {
2675 yield return false;
2676 }
2677 }
2678 }
2679 }
2680 }
2681 {
2682 object Tokens = arg3;
2683 Variable NextCh = new Variable();
2684 foreach (bool l2 in YP.unify(arg1, 46))
2685 {
2686 foreach (bool l3 in YP.get_code(NextCh))
2687 {
2688 foreach (bool l4 in read_fullstop(NextCh, Dict, Tokens))
2689 {
2690 yield return false;
2691 }
2692 }
2693 }
2694 }
2695 {
2696 Variable Chars = new Variable();
2697 Variable Tokens = new Variable();
2698 Variable NextCh = new Variable();
2699 foreach (bool l2 in YP.unify(arg1, 34))
2700 {
2701 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens)))
2702 {
2703 foreach (bool l4 in read_string(Chars, 34, NextCh))
2704 {
2705 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
2706 {
2707 yield return false;
2708 }
2709 }
2710 }
2711 }
2712 }
2713 {
2714 object Tokens = arg3;
2715 Variable Chars = new Variable();
2716 Variable NextCh = new Variable();
2717 foreach (bool l2 in YP.unify(arg1, 39))
2718 {
2719 foreach (bool l3 in read_string(Chars, 39, NextCh))
2720 {
2721 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, Chars))
2722 {
2723 yield return false;
2724 }
2725 }
2726 }
2727 }
2728 {
2729 object Tokens = arg3;
2730 foreach (bool l2 in YP.unify(arg1, 35))
2731 {
2732 foreach (bool l3 in read_symbol(35, Dict, Tokens))
2733 {
2734 yield return false;
2735 }
2736 }
2737 }
2738 {
2739 object Tokens = arg3;
2740 foreach (bool l2 in YP.unify(arg1, 36))
2741 {
2742 foreach (bool l3 in read_symbol(36, Dict, Tokens))
2743 {
2744 yield return false;
2745 }
2746 }
2747 }
2748 {
2749 object Tokens = arg3;
2750 foreach (bool l2 in YP.unify(arg1, 38))
2751 {
2752 foreach (bool l3 in read_symbol(38, Dict, Tokens))
2753 {
2754 yield return false;
2755 }
2756 }
2757 }
2758 {
2759 object Tokens = arg3;
2760 foreach (bool l2 in YP.unify(arg1, 42))
2761 {
2762 foreach (bool l3 in read_symbol(42, Dict, Tokens))
2763 {
2764 yield return false;
2765 }
2766 }
2767 }
2768 {
2769 object Tokens = arg3;
2770 foreach (bool l2 in YP.unify(arg1, 43))
2771 {
2772 foreach (bool l3 in read_symbol(43, Dict, Tokens))
2773 {
2774 yield return false;
2775 }
2776 }
2777 }
2778 {
2779 object Tokens = arg3;
2780 foreach (bool l2 in YP.unify(arg1, 45))
2781 {
2782 foreach (bool l3 in read_symbol(45, Dict, Tokens))
2783 {
2784 yield return false;
2785 }
2786 }
2787 }
2788 {
2789 object Tokens = arg3;
2790 foreach (bool l2 in YP.unify(arg1, 58))
2791 {
2792 foreach (bool l3 in read_symbol(58, Dict, Tokens))
2793 {
2794 yield return false;
2795 }
2796 }
2797 }
2798 {
2799 object Tokens = arg3;
2800 foreach (bool l2 in YP.unify(arg1, 60))
2801 {
2802 foreach (bool l3 in read_symbol(60, Dict, Tokens))
2803 {
2804 yield return false;
2805 }
2806 }
2807 }
2808 {
2809 object Tokens = arg3;
2810 foreach (bool l2 in YP.unify(arg1, 61))
2811 {
2812 foreach (bool l3 in read_symbol(61, Dict, Tokens))
2813 {
2814 yield return false;
2815 }
2816 }
2817 }
2818 {
2819 object Tokens = arg3;
2820 foreach (bool l2 in YP.unify(arg1, 62))
2821 {
2822 foreach (bool l3 in read_symbol(62, Dict, Tokens))
2823 {
2824 yield return false;
2825 }
2826 }
2827 }
2828 {
2829 object Tokens = arg3;
2830 foreach (bool l2 in YP.unify(arg1, 63))
2831 {
2832 foreach (bool l3 in read_symbol(63, Dict, Tokens))
2833 {
2834 yield return false;
2835 }
2836 }
2837 }
2838 {
2839 object Tokens = arg3;
2840 foreach (bool l2 in YP.unify(arg1, 64))
2841 {
2842 foreach (bool l3 in read_symbol(64, Dict, Tokens))
2843 {
2844 yield return false;
2845 }
2846 }
2847 }
2848 {
2849 object Tokens = arg3;
2850 foreach (bool l2 in YP.unify(arg1, 92))
2851 {
2852 foreach (bool l3 in read_symbol(92, Dict, Tokens))
2853 {
2854 yield return false;
2855 }
2856 }
2857 }
2858 {
2859 object Tokens = arg3;
2860 foreach (bool l2 in YP.unify(arg1, 94))
2861 {
2862 foreach (bool l3 in read_symbol(94, Dict, Tokens))
2863 {
2864 yield return false;
2865 }
2866 }
2867 }
2868 {
2869 object Tokens = arg3;
2870 foreach (bool l2 in YP.unify(arg1, 96))
2871 {
2872 foreach (bool l3 in read_symbol(96, Dict, Tokens))
2873 {
2874 yield return false;
2875 }
2876 }
2877 }
2878 {
2879 object Tokens = arg3;
2880 foreach (bool l2 in YP.unify(arg1, 126))
2881 {
2882 foreach (bool l3 in read_symbol(126, Dict, Tokens))
2883 {
2884 yield return false;
2885 }
2886 }
2887 }
2888 }
2889
2890 public static IEnumerable<bool> read_symbol(object C1, object Dict, object Tokens)
2891 {
2892 {
2893 Variable C2 = new Variable();
2894 Variable Chars = new Variable();
2895 Variable NextCh = new Variable();
2896 foreach (bool l2 in YP.get_code(C2))
2897 {
2898 foreach (bool l3 in rest_symbol(C2, Chars, NextCh))
2899 {
2900 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(C1, Chars)))
2901 {
2902 yield return false;
2903 }
2904 }
2905 }
2906 }
2907 }
2908
2909 public static IEnumerable<bool> rest_symbol(object arg1, object arg2, object arg3)
2910 {
2911 {
2912 object C2 = arg1;
2913 object LastCh = arg3;
2914 Variable Chars = new Variable();
2915 Variable NextCh = new Variable();
2916 foreach (bool l2 in YP.unify(arg2, new ListPair(C2, Chars)))
2917 {
2918 if (YP.greaterThan(C2, 160))
2919 {
2920 if (YP.lessThan(C2, 192))
2921 {
2922 if (YP.notEqual(C2, 186))
2923 {
2924 if (YP.notEqual(C2, 170))
2925 {
2926 foreach (bool l7 in YP.get_code(NextCh))
2927 {
2928 foreach (bool l8 in rest_symbol(NextCh, Chars, LastCh))
2929 {
2930 yield return false;
2931 }
2932 }
2933 yield break;
2934 }
2935 }
2936 }
2937 goto cutIf1;
2938 }
2939 foreach (bool l3 in symbol_char(C2))
2940 {
2941 foreach (bool l4 in YP.get_code(NextCh))
2942 {
2943 foreach (bool l5 in rest_symbol(NextCh, Chars, LastCh))
2944 {
2945 yield return false;
2946 }
2947 }
2948 yield break;
2949 }
2950 cutIf1:
2951 { }
2952 }
2953 }
2954 {
2955 Variable C2 = new Variable();
2956 foreach (bool l2 in YP.unify(arg1, C2))
2957 {
2958 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2959 {
2960 foreach (bool l4 in YP.unify(arg3, C2))
2961 {
2962 yield return false;
2963 }
2964 }
2965 }
2966 }
2967 }
2968
2969 public static IEnumerable<bool> symbol_char(object arg1)
2970 {
2971 {
2972 foreach (bool l2 in YP.unify(arg1, 35))
2973 {
2974 yield return false;
2975 }
2976 }
2977 {
2978 foreach (bool l2 in YP.unify(arg1, 36))
2979 {
2980 yield return false;
2981 }
2982 }
2983 {
2984 foreach (bool l2 in YP.unify(arg1, 38))
2985 {
2986 yield return false;
2987 }
2988 }
2989 {
2990 foreach (bool l2 in YP.unify(arg1, 42))
2991 {
2992 yield return false;
2993 }
2994 }
2995 {
2996 foreach (bool l2 in YP.unify(arg1, 43))
2997 {
2998 yield return false;
2999 }
3000 }
3001 {
3002 foreach (bool l2 in YP.unify(arg1, 45))
3003 {
3004 yield return false;
3005 }
3006 }
3007 {
3008 foreach (bool l2 in YP.unify(arg1, 46))
3009 {
3010 yield return false;
3011 }
3012 }
3013 {
3014 foreach (bool l2 in YP.unify(arg1, 47))
3015 {
3016 yield return false;
3017 }
3018 }
3019 {
3020 foreach (bool l2 in YP.unify(arg1, 58))
3021 {
3022 yield return false;
3023 }
3024 }
3025 {
3026 foreach (bool l2 in YP.unify(arg1, 60))
3027 {
3028 yield return false;
3029 }
3030 }
3031 {
3032 foreach (bool l2 in YP.unify(arg1, 61))
3033 {
3034 yield return false;
3035 }
3036 }
3037 {
3038 foreach (bool l2 in YP.unify(arg1, 62))
3039 {
3040 yield return false;
3041 }
3042 }
3043 {
3044 foreach (bool l2 in YP.unify(arg1, 63))
3045 {
3046 yield return false;
3047 }
3048 }
3049 {
3050 foreach (bool l2 in YP.unify(arg1, 64))
3051 {
3052 yield return false;
3053 }
3054 }
3055 {
3056 foreach (bool l2 in YP.unify(arg1, 92))
3057 {
3058 yield return false;
3059 }
3060 }
3061 {
3062 foreach (bool l2 in YP.unify(arg1, 94))
3063 {
3064 yield return false;
3065 }
3066 }
3067 {
3068 foreach (bool l2 in YP.unify(arg1, 96))
3069 {
3070 yield return false;
3071 }
3072 }
3073 {
3074 foreach (bool l2 in YP.unify(arg1, 126))
3075 {
3076 yield return false;
3077 }
3078 }
3079 }
3080
3081 public static IEnumerable<bool> get_current_position(object Pos)
3082 {
3083 {
3084 foreach (bool l2 in YP.unify(Pos, 0))
3085 {
3086 yield return false;
3087 }
3088 }
3089 }
3090
3091 public static IEnumerable<bool> read_after_atom4(object Ch, object Dict, object arg3, object Chars)
3092 {
3093 {
3094 Variable Atom_1 = new Variable();
3095 Variable Pos = new Variable();
3096 Variable Tokens = new Variable();
3097 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens)))
3098 {
3099 foreach (bool l3 in YP.unify(Pos, 0))
3100 {
3101 foreach (bool l4 in YP.atom_codes(Atom_1, Chars))
3102 {
3103 foreach (bool l5 in read_after_atom(Ch, Dict, Tokens))
3104 {
3105 yield return false;
3106 }
3107 }
3108 }
3109 }
3110 }
3111 }
3112
3113 public static IEnumerable<bool> read_after_atom(object arg1, object Dict, object arg3)
3114 {
3115 {
3116 Variable Tokens = new Variable();
3117 Variable NextCh = new Variable();
3118 foreach (bool l2 in YP.unify(arg1, 40))
3119 {
3120 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens)))
3121 {
3122 foreach (bool l4 in YP.get_code(NextCh))
3123 {
3124 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
3125 {
3126 yield return false;
3127 }
3128 }
3129 yield break;
3130 }
3131 }
3132 }
3133 {
3134 object Ch = arg1;
3135 object Tokens = arg3;
3136 foreach (bool l2 in read_tokens(Ch, Dict, Tokens))
3137 {
3138 yield return false;
3139 }
3140 }
3141 }
3142
3143 public static IEnumerable<bool> read_string(object Chars, object Quote, object NextCh)
3144 {
3145 {
3146 Variable Ch = new Variable();
3147 Variable Char = new Variable();
3148 Variable Next = new Variable();
3149 foreach (bool l2 in YP.get_code(Ch))
3150 {
3151 foreach (bool l3 in read_char(Ch, Quote, Char, Next))
3152 {
3153 foreach (bool l4 in rest_string5(Char, Next, Chars, Quote, NextCh))
3154 {
3155 yield return false;
3156 }
3157 }
3158 }
3159 }
3160 }
3161
3162 public static IEnumerable<bool> rest_string5(object arg1, object arg2, object arg3, object arg4, object arg5)
3163 {
3164 {
3165 object _X = arg4;
3166 Variable NextCh = new Variable();
3167 foreach (bool l2 in YP.unify(arg1, -1))
3168 {
3169 foreach (bool l3 in YP.unify(arg2, NextCh))
3170 {
3171 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
3172 {
3173 foreach (bool l5 in YP.unify(arg5, NextCh))
3174 {
3175 yield return true;
3176 yield break;
3177 }
3178 }
3179 }
3180 }
3181 }
3182 {
3183 object Char = arg1;
3184 object Next = arg2;
3185 object Quote = arg4;
3186 object NextCh = arg5;
3187 Variable Chars = new Variable();
3188 Variable Char2 = new Variable();
3189 Variable Next2 = new Variable();
3190 foreach (bool l2 in YP.unify(arg3, new ListPair(Char, Chars)))
3191 {
3192 foreach (bool l3 in read_char(Next, Quote, Char2, Next2))
3193 {
3194 foreach (bool l4 in rest_string5(Char2, Next2, Chars, Quote, NextCh))
3195 {
3196 yield return false;
3197 }
3198 }
3199 }
3200 }
3201 }
3202
3203 public static IEnumerable<bool> escape_char(object arg1, object arg2)
3204 {
3205 {
3206 foreach (bool l2 in YP.unify(arg1, 110))
3207 {
3208 foreach (bool l3 in YP.unify(arg2, 10))
3209 {
3210 yield return false;
3211 }
3212 }
3213 }
3214 {
3215 foreach (bool l2 in YP.unify(arg1, 78))
3216 {
3217 foreach (bool l3 in YP.unify(arg2, 10))
3218 {
3219 yield return false;
3220 }
3221 }
3222 }
3223 {
3224 foreach (bool l2 in YP.unify(arg1, 116))
3225 {
3226 foreach (bool l3 in YP.unify(arg2, 9))
3227 {
3228 yield return false;
3229 }
3230 }
3231 }
3232 {
3233 foreach (bool l2 in YP.unify(arg1, 84))
3234 {
3235 foreach (bool l3 in YP.unify(arg2, 9))
3236 {
3237 yield return false;
3238 }
3239 }
3240 }
3241 {
3242 foreach (bool l2 in YP.unify(arg1, 114))
3243 {
3244 foreach (bool l3 in YP.unify(arg2, 13))
3245 {
3246 yield return false;
3247 }
3248 }
3249 }
3250 {
3251 foreach (bool l2 in YP.unify(arg1, 82))
3252 {
3253 foreach (bool l3 in YP.unify(arg2, 13))
3254 {
3255 yield return false;
3256 }
3257 }
3258 }
3259 {
3260 foreach (bool l2 in YP.unify(arg1, 118))
3261 {
3262 foreach (bool l3 in YP.unify(arg2, 11))
3263 {
3264 yield return false;
3265 }
3266 }
3267 }
3268 {
3269 foreach (bool l2 in YP.unify(arg1, 86))
3270 {
3271 foreach (bool l3 in YP.unify(arg2, 11))
3272 {
3273 yield return false;
3274 }
3275 }
3276 }
3277 {
3278 foreach (bool l2 in YP.unify(arg1, 98))
3279 {
3280 foreach (bool l3 in YP.unify(arg2, 8))
3281 {
3282 yield return false;
3283 }
3284 }
3285 }
3286 {
3287 foreach (bool l2 in YP.unify(arg1, 66))
3288 {
3289 foreach (bool l3 in YP.unify(arg2, 8))
3290 {
3291 yield return false;
3292 }
3293 }
3294 }
3295 {
3296 foreach (bool l2 in YP.unify(arg1, 102))
3297 {
3298 foreach (bool l3 in YP.unify(arg2, 12))
3299 {
3300 yield return false;
3301 }
3302 }
3303 }
3304 {
3305 foreach (bool l2 in YP.unify(arg1, 70))
3306 {
3307 foreach (bool l3 in YP.unify(arg2, 12))
3308 {
3309 yield return false;
3310 }
3311 }
3312 }
3313 {
3314 foreach (bool l2 in YP.unify(arg1, 101))
3315 {
3316 foreach (bool l3 in YP.unify(arg2, 27))
3317 {
3318 yield return false;
3319 }
3320 }
3321 }
3322 {
3323 foreach (bool l2 in YP.unify(arg1, 69))
3324 {
3325 foreach (bool l3 in YP.unify(arg2, 27))
3326 {
3327 yield return false;
3328 }
3329 }
3330 }
3331 {
3332 foreach (bool l2 in YP.unify(arg1, 100))
3333 {
3334 foreach (bool l3 in YP.unify(arg2, 127))
3335 {
3336 yield return false;
3337 }
3338 }
3339 }
3340 {
3341 foreach (bool l2 in YP.unify(arg1, 68))
3342 {
3343 foreach (bool l3 in YP.unify(arg2, 127))
3344 {
3345 yield return false;
3346 }
3347 }
3348 }
3349 {
3350 foreach (bool l2 in YP.unify(arg1, 115))
3351 {
3352 foreach (bool l3 in YP.unify(arg2, 32))
3353 {
3354 yield return false;
3355 }
3356 }
3357 }
3358 {
3359 foreach (bool l2 in YP.unify(arg1, 83))
3360 {
3361 foreach (bool l3 in YP.unify(arg2, 32))
3362 {
3363 yield return false;
3364 }
3365 }
3366 }
3367 {
3368 foreach (bool l2 in YP.unify(arg1, 122))
3369 {
3370 foreach (bool l3 in YP.unify(arg2, -1))
3371 {
3372 yield return false;
3373 }
3374 }
3375 }
3376 {
3377 foreach (bool l2 in YP.unify(arg1, 90))
3378 {
3379 foreach (bool l3 in YP.unify(arg2, -1))
3380 {
3381 yield return false;
3382 }
3383 }
3384 }
3385 }
3386
3387 public static IEnumerable<bool> read_variable(object C1, object Dict, object arg3)
3388 {
3389 {
3390 Variable Var = new Variable();
3391 Variable Name = new Variable();
3392 Variable StartPos = new Variable();
3393 Variable Tokens = new Variable();
3394 Variable Chars = new Variable();
3395 Variable NextCh = new Variable();
3396 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens)))
3397 {
3398 foreach (bool l3 in get_current_position(StartPos))
3399 {
3400 foreach (bool l4 in read_name(C1, Chars, NextCh))
3401 {
3402 foreach (bool l5 in YP.atom_codes(Name, Chars))
3403 {
3404 if (YP.termEqual(Name, Atom.a(@"_")))
3405 {
3406 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3407 {
3408 yield return false;
3409 }
3410 goto cutIf1;
3411 }
3412 foreach (bool l6 in read_lookup(Dict, Name, Var))
3413 {
3414 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3415 {
3416 yield return false;
3417 }
3418 }
3419 cutIf1:
3420 { }
3421 }
3422 }
3423 }
3424 }
3425 }
3426 }
3427
3428 public static IEnumerable<bool> read_lookup(object arg1, object Name, object Var)
3429 {
3430 {
3431 Variable N = new Variable();
3432 Variable V = new Variable();
3433 Variable L = new Variable();
3434 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L)))
3435 {
3436 foreach (bool l3 in YP.unify(N, Name))
3437 {
3438 foreach (bool l4 in YP.unify(V, Var))
3439 {
3440 yield return false;
3441 }
3442 goto cutIf1;
3443 }
3444 foreach (bool l3 in read_lookup(L, Name, Var))
3445 {
3446 yield return false;
3447 }
3448 cutIf1:
3449 { }
3450 }
3451 }
3452 }
3453
3454 public static IEnumerable<bool> read_solidus(object Ch, object LastCh)
3455 {
3456 {
3457 Variable NextCh = new Variable();
3458 if (YP.equal(Ch, 42))
3459 {
3460 foreach (bool l3 in YP.get_code(NextCh))
3461 {
3462 if (YP.equal(NextCh, 47))
3463 {
3464 foreach (bool l5 in YP.get_code(LastCh))
3465 {
3466 yield return false;
3467 }
3468 goto cutIf2;
3469 }
3470 foreach (bool l4 in read_solidus(NextCh, LastCh))
3471 {
3472 yield return false;
3473 }
3474 cutIf2:
3475 { }
3476 }
3477 goto cutIf1;
3478 }
3479 if (YP.notEqual(Ch, -1))
3480 {
3481 foreach (bool l3 in YP.get_code(NextCh))
3482 {
3483 foreach (bool l4 in read_solidus(NextCh, LastCh))
3484 {
3485 yield return false;
3486 }
3487 }
3488 goto cutIf3;
3489 }
3490 foreach (bool l2 in YP.unify(LastCh, Ch))
3491 {
3492 foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL))
3493 {
3494 yield return false;
3495 }
3496 }
3497 cutIf3:
3498 cutIf1:
3499 { }
3500 }
3501 }
3502
3503 public static IEnumerable<bool> read_identifier(object C1, object Dict, object Tokens)
3504 {
3505 {
3506 Variable Chars = new Variable();
3507 Variable NextCh = new Variable();
3508 foreach (bool l2 in read_name(C1, Chars, NextCh))
3509 {
3510 foreach (bool l3 in read_after_atom4(NextCh, Dict, Tokens, Chars))
3511 {
3512 yield return false;
3513 }
3514 }
3515 }
3516 }
3517
3518 public static IEnumerable<bool> read_name(object C1, object arg2, object LastCh)
3519 {
3520 {
3521 Variable Chars = new Variable();
3522 Variable C2 = new Variable();
3523 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3524 {
3525 foreach (bool l3 in YP.get_code(C2))
3526 {
3527 if (YP.greaterThanOrEqual(C2, new ListPair(97, Atom.NIL)))
3528 {
3529 if (YP.lessThanOrEqual(C2, new ListPair(122, Atom.NIL)))
3530 {
3531 foreach (bool l6 in read_name(C2, Chars, LastCh))
3532 {
3533 yield return false;
3534 }
3535 goto cutIf2;
3536 }
3537 if (YP.lessThan(C2, 192))
3538 {
3539 if (YP.notEqual(YP.bitwiseOr(C2, 16), 186))
3540 {
3541 foreach (bool l7 in YP.unify(Chars, Atom.NIL))
3542 {
3543 foreach (bool l8 in YP.unify(LastCh, C2))
3544 {
3545 yield return false;
3546 }
3547 }
3548 goto cutIf3;
3549 }
3550 }
3551 if (YP.equal(YP.bitwiseOr(C2, 32), 247))
3552 {
3553 foreach (bool l6 in YP.unify(Chars, Atom.NIL))
3554 {
3555 foreach (bool l7 in YP.unify(LastCh, C2))
3556 {
3557 yield return false;
3558 }
3559 }
3560 goto cutIf4;
3561 }
3562 foreach (bool l5 in read_name(C2, Chars, LastCh))
3563 {
3564 yield return false;
3565 }
3566 cutIf4:
3567 cutIf3:
3568 cutIf2:
3569 goto cutIf1;
3570 }
3571 if (YP.greaterThanOrEqual(C2, new ListPair(65, Atom.NIL)))
3572 {
3573 if (YP.greaterThan(C2, new ListPair(90, Atom.NIL)))
3574 {
3575 if (YP.notEqual(C2, new ListPair(95, Atom.NIL)))
3576 {
3577 foreach (bool l7 in YP.unify(Chars, Atom.NIL))
3578 {
3579 foreach (bool l8 in YP.unify(LastCh, C2))
3580 {
3581 yield return false;
3582 }
3583 }
3584 goto cutIf6;
3585 }
3586 }
3587 foreach (bool l5 in read_name(C2, Chars, LastCh))
3588 {
3589 yield return false;
3590 }
3591 cutIf6:
3592 goto cutIf5;
3593 }
3594 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3595 {
3596 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3597 {
3598 foreach (bool l6 in read_name(C2, Chars, LastCh))
3599 {
3600 yield return false;
3601 }
3602 goto cutIf7;
3603 }
3604 }
3605 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3606 {
3607 foreach (bool l5 in YP.unify(LastCh, C2))
3608 {
3609 yield return false;
3610 }
3611 }
3612 cutIf7:
3613 cutIf5:
3614 cutIf1:
3615 { }
3616 }
3617 }
3618 }
3619 }
3620
3621 public static IEnumerable<bool> read_fullstop(object Ch, object Dict, object Tokens)
3622 {
3623 {
3624 Variable Number = new Variable();
3625 Variable Tokens1 = new Variable();
3626 Variable Chars = new Variable();
3627 Variable NextCh = new Variable();
3628 if (YP.lessThanOrEqual(Ch, new ListPair(57, Atom.NIL)))
3629 {
3630 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL)))
3631 {
3632 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1)))
3633 {
3634 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch))
3635 {
3636 yield return false;
3637 }
3638 }
3639 goto cutIf1;
3640 }
3641 }
3642 if (YP.greaterThan(Ch, new ListPair(32, Atom.NIL)))
3643 {
3644 foreach (bool l3 in rest_symbol(Ch, Chars, NextCh))
3645 {
3646 foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(46, Chars)))
3647 {
3648 yield return false;
3649 }
3650 }
3651 goto cutIf2;
3652 }
3653 if (YP.greaterThanOrEqual(Ch, 0))
3654 {
3655 foreach (bool l3 in YP.unify(Tokens, Atom.NIL))
3656 {
3657 yield return false;
3658 }
3659 goto cutIf3;
3660 }
3661 foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL))
3662 {
3663 }
3664 cutIf3:
3665 cutIf2:
3666 cutIf1:
3667 { }
3668 }
3669 }
3670
3671 public static IEnumerable<bool> read_float(object Number, object Dict, object Tokens, object Digits, object Digit)
3672 {
3673 {
3674 Variable Chars = new Variable();
3675 Variable Rest = new Variable();
3676 Variable NextCh = new Variable();
3677 foreach (bool l2 in prepend(Digits, Chars, Rest))
3678 {
3679 foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars))
3680 {
3681 foreach (bool l4 in YP.number_codes(Number, Chars))
3682 {
3683 foreach (bool l5 in read_tokens(NextCh, Dict, Tokens))
3684 {
3685 yield return false;
3686 }
3687 }
3688 }
3689 }
3690 }
3691 }
3692
3693 public static IEnumerable<bool> prepend(object arg1, object arg2, object arg3)
3694 {
3695 {
3696 object X = arg3;
3697 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3698 {
3699 foreach (bool l3 in YP.unify(arg2, new ListPair(46, X)))
3700 {
3701 yield return false;
3702 }
3703 }
3704 }
3705 {
3706 object Y = arg3;
3707 Variable C = new Variable();
3708 Variable Cs = new Variable();
3709 Variable X = new Variable();
3710 foreach (bool l2 in YP.unify(arg1, new ListPair(C, Cs)))
3711 {
3712 foreach (bool l3 in YP.unify(arg2, new ListPair(C, X)))
3713 {
3714 foreach (bool l4 in prepend(Cs, X, Y))
3715 {
3716 yield return false;
3717 }
3718 }
3719 }
3720 }
3721 }
3722
3723 public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total)
3724 {
3725 {
3726 Variable Chars = new Variable();
3727 Variable C2 = new Variable();
3728 Variable C3 = new Variable();
3729 Variable C4 = new Variable();
3730 Variable More = new Variable();
3731 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3732 {
3733 foreach (bool l3 in YP.get_code(C2))
3734 {
3735 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3736 {
3737 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3738 {
3739 foreach (bool l6 in read_float(C2, Chars, NextCh, Total))
3740 {
3741 yield return false;
3742 }
3743 goto cutIf1;
3744 }
3745 }
3746 if (YP.equal(YP.bitwiseOr(C2, 32), new ListPair(101, Atom.NIL)))
3747 {
3748 foreach (bool l5 in YP.get_code(C3))
3749 {
3750 if (YP.equal(C3, new ListPair(45, Atom.NIL)))
3751 {
3752 foreach (bool l7 in YP.get_code(C4))
3753 {
3754 foreach (bool l8 in YP.unify(Chars, new ListPair(C2, new ListPair(45, More))))
3755 {
3756 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3757 {
3758 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3759 {
3760 foreach (bool l11 in read_exponent(C4, More, NextCh))
3761 {
3762 yield return false;
3763 }
3764 goto cutIf4;
3765 }
3766 }
3767 foreach (bool l9 in YP.unify(More, Atom.NIL))
3768 {
3769 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3770 {
3771 }
3772 }
3773 foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL)))
3774 {
3775 foreach (bool l10 in YP.unify(NextCh, C4))
3776 {
3777 yield return false;
3778 }
3779 }
3780 cutIf4:
3781 { }
3782 }
3783 }
3784 goto cutIf3;
3785 }
3786 if (YP.equal(C3, new ListPair(43, Atom.NIL)))
3787 {
3788 foreach (bool l7 in YP.get_code(C4))
3789 {
3790 foreach (bool l8 in YP.unify(Chars, new ListPair(C2, More)))
3791 {
3792 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3793 {
3794 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3795 {
3796 foreach (bool l11 in read_exponent(C4, More, NextCh))
3797 {
3798 yield return false;
3799 }
3800 goto cutIf6;
3801 }
3802 }
3803 foreach (bool l9 in YP.unify(More, Atom.NIL))
3804 {
3805 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3806 {
3807 }
3808 }
3809 foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL)))
3810 {
3811 foreach (bool l10 in YP.unify(NextCh, C4))
3812 {
3813 yield return false;
3814 }
3815 }
3816 cutIf6:
3817 { }
3818 }
3819 }
3820 goto cutIf5;
3821 }
3822 foreach (bool l6 in YP.unify(C4, C3))
3823 {
3824 foreach (bool l7 in YP.unify(Chars, new ListPair(C2, More)))
3825 {
3826 if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL)))
3827 {
3828 if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL)))
3829 {
3830 foreach (bool l10 in read_exponent(C4, More, NextCh))
3831 {
3832 yield return false;
3833 }
3834 goto cutIf7;
3835 }
3836 }
3837 foreach (bool l8 in YP.unify(More, Atom.NIL))
3838 {
3839 foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3840 {
3841 }
3842 }
3843 foreach (bool l8 in YP.unify(More, new ListPair(48, Atom.NIL)))
3844 {
3845 foreach (bool l9 in YP.unify(NextCh, C4))
3846 {
3847 yield return false;
3848 }
3849 }
3850 cutIf7:
3851 { }
3852 }
3853 }
3854 cutIf5:
3855 cutIf3:
3856 { }
3857 }
3858 goto cutIf2;
3859 }
3860 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3861 {
3862 foreach (bool l5 in YP.unify(NextCh, C2))
3863 {
3864 yield return false;
3865 }
3866 }
3867 cutIf2:
3868 cutIf1:
3869 { }
3870 }
3871 }
3872 }
3873 }
3874
3875 public static IEnumerable<bool> read_exponent(object C1, object arg2, object NextCh)
3876 {
3877 {
3878 Variable Chars = new Variable();
3879 Variable C2 = new Variable();
3880 foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars)))
3881 {
3882 foreach (bool l3 in YP.get_code(C2))
3883 {
3884 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
3885 {
3886 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3887 {
3888 foreach (bool l6 in read_exponent(C2, Chars, NextCh))
3889 {
3890 yield return false;
3891 }
3892 goto cutIf1;
3893 }
3894 }
3895 foreach (bool l4 in YP.unify(Chars, Atom.NIL))
3896 {
3897 foreach (bool l5 in YP.unify(NextCh, C2))
3898 {
3899 yield return false;
3900 }
3901 }
3902 cutIf1:
3903 { }
3904 }
3905 }
3906 }
3907 }
3908
3909 public static IEnumerable<bool> read_number(object C1, object Dict, object arg3)
3910 {
3911 {
3912 Variable Number = new Variable();
3913 Variable Tokens = new Variable();
3914 Variable C2 = new Variable();
3915 Variable N = new Variable();
3916 Variable C = new Variable();
3917 Variable C3 = new Variable();
3918 Variable Digits = new Variable();
3919 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens)))
3920 {
3921 foreach (bool l3 in read_number4(C1, C2, 0, N))
3922 {
3923 if (YP.equal(C2, 39))
3924 {
3925 if (YP.greaterThanOrEqual(N, 2))
3926 {
3927 if (YP.lessThanOrEqual(N, 36))
3928 {
3929 foreach (bool l7 in read_based(N, 0, Number, C))
3930 {
3931 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3932 {
3933 yield return false;
3934 }
3935 }
3936 goto cutIf2;
3937 }
3938 }
3939 if (YP.equal(N, 0))
3940 {
3941 foreach (bool l6 in YP.get_code(C3))
3942 {
3943 foreach (bool l7 in read_char(C3, -1, Number, C))
3944 {
3945 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3946 {
3947 yield return false;
3948 }
3949 }
3950 }
3951 goto cutIf3;
3952 }
3953 foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** ~d' read as ~d '~n"), new ListPair(N, new ListPair(N, Atom.NIL))))
3954 {
3955 foreach (bool l6 in YP.unify(Number, N))
3956 {
3957 foreach (bool l7 in YP.unify(C, C2))
3958 {
3959 foreach (bool l8 in read_tokens(C, Dict, Tokens))
3960 {
3961 yield return false;
3962 }
3963 }
3964 }
3965 }
3966 cutIf3:
3967 cutIf2:
3968 goto cutIf1;
3969 }
3970 if (YP.equal(C2, 46))
3971 {
3972 foreach (bool l5 in YP.get_code(C3))
3973 {
3974 if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL)))
3975 {
3976 if (YP.lessThanOrEqual(C3, new ListPair(57, Atom.NIL)))
3977 {
3978 foreach (bool l8 in YP.number_codes(N, Digits))
3979 {
3980 foreach (bool l9 in read_float(Number, Dict, Tokens, Digits, C3))
3981 {
3982 yield return false;
3983 }
3984 }
3985 goto cutIf5;
3986 }
3987 }
3988 foreach (bool l6 in YP.unify(Number, N))
3989 {
3990 foreach (bool l7 in read_fullstop(C3, Dict, Tokens))
3991 {
3992 yield return false;
3993 }
3994 }
3995 cutIf5:
3996 { }
3997 }
3998 goto cutIf4;
3999 }
4000 foreach (bool l4 in YP.unify(Number, N))
4001 {
4002 foreach (bool l5 in read_tokens(C2, Dict, Tokens))
4003 {
4004 yield return false;
4005 }
4006 }
4007 cutIf4:
4008 cutIf1:
4009 { }
4010 }
4011 }
4012 }
4013 }
4014
4015 public static IEnumerable<bool> read_number4(object C0, object C, object N0, object N)
4016 {
4017 {
4018 Variable N1 = new Variable();
4019 Variable C1 = new Variable();
4020 if (YP.greaterThanOrEqual(C0, new ListPair(48, Atom.NIL)))
4021 {
4022 if (YP.lessThanOrEqual(C0, new ListPair(57, Atom.NIL)))
4023 {
4024 foreach (bool l4 in YP.unify(N1, YP.add(YP.subtract(YP.multiply(N0, 10), new ListPair(48, Atom.NIL)), C0)))
4025 {
4026 foreach (bool l5 in YP.get_code(C1))
4027 {
4028 foreach (bool l6 in read_number4(C1, C, N1, N))
4029 {
4030 yield return false;
4031 }
4032 }
4033 }
4034 goto cutIf1;
4035 }
4036 }
4037 if (YP.equal(C0, 95))
4038 {
4039 foreach (bool l3 in YP.get_code(C1))
4040 {
4041 foreach (bool l4 in read_number4(C1, C, N0, N))
4042 {
4043 yield return false;
4044 }
4045 }
4046 goto cutIf2;
4047 }
4048 foreach (bool l2 in YP.unify(C, C0))
4049 {
4050 foreach (bool l3 in YP.unify(N, N0))
4051 {
4052 yield return false;
4053 }
4054 }
4055 cutIf2:
4056 cutIf1:
4057 { }
4058 }
4059 }
4060
4061 public static IEnumerable<bool> read_based(object Base, object N0, object N, object C)
4062 {
4063 {
4064 Variable C1 = new Variable();
4065 Variable Digit = new Variable();
4066 Variable N1 = new Variable();
4067 foreach (bool l2 in YP.get_code(C1))
4068 {
4069 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
4070 {
4071 if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
4072 {
4073 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, new ListPair(48, Atom.NIL))))
4074 {
4075 if (YP.lessThan(Digit, Base))
4076 {
4077 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4078 {
4079 foreach (bool l8 in read_based(Base, N1, N, C))
4080 {
4081 yield return false;
4082 }
4083 }
4084 goto cutIf2;
4085 }
4086 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4087 {
4088 foreach (bool l7 in read_based(Base, N0, N, C))
4089 {
4090 yield return false;
4091 }
4092 goto cutIf3;
4093 }
4094 foreach (bool l6 in YP.unify(N, N0))
4095 {
4096 foreach (bool l7 in YP.unify(C, C1))
4097 {
4098 yield return false;
4099 }
4100 }
4101 cutIf3:
4102 cutIf2:
4103 { }
4104 }
4105 goto cutIf1;
4106 }
4107 }
4108 if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
4109 {
4110 if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
4111 {
4112 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(65, Atom.NIL), 10))))
4113 {
4114 if (YP.lessThan(Digit, Base))
4115 {
4116 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4117 {
4118 foreach (bool l8 in read_based(Base, N1, N, C))
4119 {
4120 yield return false;
4121 }
4122 }
4123 goto cutIf5;
4124 }
4125 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4126 {
4127 foreach (bool l7 in read_based(Base, N0, N, C))
4128 {
4129 yield return false;
4130 }
4131 goto cutIf6;
4132 }
4133 foreach (bool l6 in YP.unify(N, N0))
4134 {
4135 foreach (bool l7 in YP.unify(C, C1))
4136 {
4137 yield return false;
4138 }
4139 }
4140 cutIf6:
4141 cutIf5:
4142 { }
4143 }
4144 goto cutIf4;
4145 }
4146 }
4147 if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
4148 {
4149 if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
4150 {
4151 foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(97, Atom.NIL), 10))))
4152 {
4153 if (YP.lessThan(Digit, Base))
4154 {
4155 foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4156 {
4157 foreach (bool l8 in read_based(Base, N1, N, C))
4158 {
4159 yield return false;
4160 }
4161 }
4162 goto cutIf8;
4163 }
4164 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4165 {
4166 foreach (bool l7 in read_based(Base, N0, N, C))
4167 {
4168 yield return false;
4169 }
4170 goto cutIf9;
4171 }
4172 foreach (bool l6 in YP.unify(N, N0))
4173 {
4174 foreach (bool l7 in YP.unify(C, C1))
4175 {
4176 yield return false;
4177 }
4178 }
4179 cutIf9:
4180 cutIf8:
4181 { }
4182 }
4183 goto cutIf7;
4184 }
4185 }
4186 foreach (bool l3 in YP.unify(Digit, 99))
4187 {
4188 if (YP.lessThan(Digit, Base))
4189 {
4190 foreach (bool l5 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit)))
4191 {
4192 foreach (bool l6 in read_based(Base, N1, N, C))
4193 {
4194 yield return false;
4195 }
4196 }
4197 goto cutIf10;
4198 }
4199 if (YP.equal(C1, new ListPair(95, Atom.NIL)))
4200 {
4201 foreach (bool l5 in read_based(Base, N0, N, C))
4202 {
4203 yield return false;
4204 }
4205 goto cutIf11;
4206 }
4207 foreach (bool l4 in YP.unify(N, N0))
4208 {
4209 foreach (bool l5 in YP.unify(C, C1))
4210 {
4211 yield return false;
4212 }
4213 }
4214 cutIf11:
4215 cutIf10:
4216 { }
4217 }
4218 cutIf7:
4219 cutIf4:
4220 cutIf1:
4221 { }
4222 }
4223 }
4224 }
4225
4226 public static IEnumerable<bool> read_char(object Char, object Quote, object Result, object Next)
4227 {
4228 {
4229 Variable C1 = new Variable();
4230 Variable C2 = new Variable();
4231 Variable C3 = new Variable();
4232 Variable Ch = new Variable();
4233 if (YP.equal(Char, 92))
4234 {
4235 foreach (bool l3 in YP.get_code(C1))
4236 {
4237 if (YP.lessThan(C1, 0))
4238 {
4239 foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~cquoted~c~n"), new ListPair(Quote, new ListPair(Quote, Atom.NIL))))
4240 {
4241 foreach (bool l6 in YP.unify(Result, -1))
4242 {
4243 foreach (bool l7 in YP.unify(Next, C1))
4244 {
4245 yield return false;
4246 }
4247 }
4248 }
4249 goto cutIf2;
4250 }
4251 if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
4252 {
4253 foreach (bool l5 in YP.get_code(C2))
4254 {
4255 foreach (bool l6 in read_char(C2, Quote, Result, Next))
4256 {
4257 yield return false;
4258 }
4259 }
4260 goto cutIf3;
4261 }
4262 if (YP.equal(YP.bitwiseOr(C1, 32), new ListPair(99, Atom.NIL)))
4263 {
4264 foreach (bool l5 in YP.get_code(C2))
4265 {
4266 foreach (bool l6 in read_char(C2, Quote, Result, Next))
4267 {
4268 yield return false;
4269 }
4270 }
4271 goto cutIf4;
4272 }
4273 if (YP.lessThanOrEqual(C1, new ListPair(55, Atom.NIL)))
4274 {
4275 if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
4276 {
4277 foreach (bool l6 in YP.get_code(C2))
4278 {
4279 if (YP.lessThanOrEqual(C2, new ListPair(55, Atom.NIL)))
4280 {
4281 if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL)))
4282 {
4283 foreach (bool l9 in YP.get_code(C3))
4284 {
4285 if (YP.lessThanOrEqual(C3, new ListPair(55, Atom.NIL)))
4286 {
4287 if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL)))
4288 {
4289 foreach (bool l12 in YP.get_code(Next))
4290 {
4291 foreach (bool l13 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(YP.add(YP.multiply(C1, 8), C2), 8), C3), YP.multiply(73, new ListPair(48, Atom.NIL)))))
4292 {
4293 yield return false;
4294 }
4295 }
4296 goto cutIf7;
4297 }
4298 }
4299 foreach (bool l10 in YP.unify(Next, C3))
4300 {
4301 foreach (bool l11 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(C1, 8), C2), YP.multiply(9, new ListPair(48, Atom.NIL)))))
4302 {
4303 yield return false;
4304 }
4305 }
4306 cutIf7:
4307 { }
4308 }
4309 goto cutIf6;
4310 }
4311 }
4312 foreach (bool l7 in YP.unify(Next, C2))
4313 {
4314 foreach (bool l8 in YP.unify(Result, YP.subtract(C1, new ListPair(48, Atom.NIL))))
4315 {
4316 yield return false;
4317 }
4318 }
4319 cutIf6:
4320 { }
4321 }
4322 goto cutIf5;
4323 }
4324 }
4325 if (YP.equal(C1, new ListPair(94, Atom.NIL)))
4326 {
4327 foreach (bool l5 in YP.get_code(C2))
4328 {
4329 if (YP.lessThan(C2, 0))
4330 {
4331 foreach (bool l7 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~c..~c^..~c~n"), new ListPair(Quote, new ListPair(92, new ListPair(Quote, Atom.NIL)))))
4332 {
4333 foreach (bool l8 in YP.unify(Result, -1))
4334 {
4335 foreach (bool l9 in YP.unify(Next, C2))
4336 {
4337 yield return false;
4338 }
4339 }
4340 }
4341 goto cutIf9;
4342 }
4343 if (YP.equal(C2, new ListPair(63, Atom.NIL)))
4344 {
4345 foreach (bool l7 in YP.unify(Result, 127))
4346 {
4347 foreach (bool l8 in YP.get_code(Next))
4348 {
4349 yield return false;
4350 }
4351 }
4352 goto cutIf10;
4353 }
4354 foreach (bool l6 in YP.unify(Result, YP.bitwiseAnd(C2, 31)))
4355 {
4356 foreach (bool l7 in YP.get_code(Next))
4357 {
4358 yield return false;
4359 }
4360 }
4361 cutIf10:
4362 cutIf9:
4363 { }
4364 }
4365 goto cutIf8;
4366 }
4367 foreach (bool l4 in escape_char(C1, Result))
4368 {
4369 foreach (bool l5 in YP.get_code(Next))
4370 {
4371 yield return false;
4372 }
4373 goto cutIf11;
4374 }
4375 foreach (bool l4 in YP.unify(Result, C1))
4376 {
4377 foreach (bool l5 in YP.get_code(Next))
4378 {
4379 yield return false;
4380 }
4381 }
4382 cutIf11:
4383 cutIf8:
4384 cutIf5:
4385 cutIf4:
4386 cutIf3:
4387 cutIf2:
4388 { }
4389 }
4390 goto cutIf1;
4391 }
4392 if (YP.equal(Char, Quote))
4393 {
4394 foreach (bool l3 in YP.get_code(Ch))
4395 {
4396 if (YP.equal(Ch, Quote))
4397 {
4398 foreach (bool l5 in YP.unify(Result, Quote))
4399 {
4400 foreach (bool l6 in YP.get_code(Next))
4401 {
4402 yield return false;
4403 }
4404 }
4405 goto cutIf13;
4406 }
4407 foreach (bool l4 in YP.unify(Result, -1))
4408 {
4409 foreach (bool l5 in YP.unify(Next, Ch))
4410 {
4411 yield return false;
4412 }
4413 }
4414 cutIf13:
4415 { }
4416 }
4417 goto cutIf12;
4418 }
4419 if (YP.lessThan(Char, new ListPair(32, Atom.NIL)))
4420 {
4421 if (YP.notEqual(Char, 9))
4422 {
4423 if (YP.notEqual(Char, 10))
4424 {
4425 if (YP.notEqual(Char, 13))
4426 {
4427 foreach (bool l6 in YP.unify(Result, -1))
4428 {
4429 foreach (bool l7 in YP.unify(Next, Char))
4430 {
4431 foreach (bool l8 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Strange character ~d ends ~ctoken~c~n"), new ListPair(Char, new ListPair(Quote, new ListPair(Quote, Atom.NIL)))))
4432 {
4433 yield return false;
4434 }
4435 }
4436 }
4437 goto cutIf14;
4438 }
4439 }
4440 }
4441 }
4442 foreach (bool l2 in YP.unify(Result, Char))
4443 {
4444 foreach (bool l3 in YP.get_code(Next))
4445 {
4446 yield return false;
4447 }
4448 }
4449 cutIf14:
4450 cutIf12:
4451 cutIf1:
4452 { }
4453 }
4454 }
4455
4456 }
4457}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
new file mode 100644
index 0000000..f29c751
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/PrologException.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32
33namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
34{
35 /// <summary>
36 /// A PrologException is used as the exception thrown by YP.throw(Term).
37 /// </summary>
38 public class PrologException : Exception
39 {
40 public readonly object _term;
41
42 /// <summary>
43 /// Create a PrologException with the given Term. The printable exception message is the full Term.
44 /// </summary>
45 /// <param name="Term">the term of the exception</param>
46 /// </param>
47 public PrologException(object Term)
48 : base(YP.getValue(Term).ToString())
49 {
50 _term = YP.makeCopy(Term, new Variable.CopyStore());
51 }
52
53 /// <summary>
54 /// Create a PrologException where the Term is error(ErrorTerm, Message).
55 /// This uses YP.makeCopy to copy the ErrorTerm and Message so that they are valid after unbinding.
56 /// </summary>
57 /// <param name="ErrorTerm">the term of the exception</param>
58 /// <param name="Messsage">the message, converted to a string, to use as the printable exception message
59 /// </param>
60 public PrologException(object ErrorTerm, object Message)
61 : base(YP.getValue(Message).ToString())
62 {
63 _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore());
64 }
65
66 public object Term
67 {
68 get { return _term; }
69 }
70 }
71}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs
new file mode 100644
index 0000000..4b6112f
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/UndefinedPredicateException.cs
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32
33namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
34{
35 /// <summary>
36 /// An UndefinedPredicateException extends PrologException to create an existence_error exception.
37 /// </summary>
38 public class UndefinedPredicateException : PrologException
39 {
40 private Atom _predicateName;
41 private int _arity;
42
43 public UndefinedPredicateException(object message, Atom predicateName, int arity)
44 : base(new Functor2
45 (Atom.a("existence_error"), Atom.a("procedure"), new Functor2(Atom.a("/"), predicateName, arity)),
46 message)
47 {
48 _predicateName = predicateName;
49 _arity = arity;
50 }
51
52 public Atom PredicateName
53 {
54 get { return _predicateName; }
55 }
56
57 public int Arity
58 {
59 get { return _arity; }
60 }
61 }
62}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
new file mode 100644
index 0000000..2b5b0f1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
@@ -0,0 +1,196 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 public interface IUnifiable
38 {
39 IEnumerable<bool> unify(object arg);
40 void addUniqueVariables(List<Variable> variableSet);
41 object makeCopy(Variable.CopyStore copyStore);
42 bool termEqual(object term);
43 bool ground();
44 }
45
46 public class Variable : IUnifiable
47 {
48 // Use _isBound separate from _value so that it can be bound to any value,
49 // including null.
50 private bool _isBound = false;
51 private object _value;
52
53 public object getValue()
54 {
55 if (!_isBound)
56 return this;
57
58 object result = _value;
59 while (result is Variable)
60 {
61 if (!((Variable)result)._isBound)
62 return result;
63
64 // Keep following the Variable chain.
65 result = ((Variable)result)._value;
66 }
67
68 return result;
69 }
70
71 public IEnumerable<bool> unify(object arg)
72 {
73 if (!_isBound)
74 {
75 _value = YP.getValue(arg);
76 if (_value == this)
77 // We are unifying this unbound variable with itself, so leave it unbound.
78 yield return false;
79 else
80 {
81 _isBound = true;
82 try
83 {
84 yield return false;
85 }
86 finally
87 {
88 // Remove the binding.
89 _isBound = false;
90 }
91 }
92 }
93 else
94 {
95 foreach (bool l1 in YP.unify(this, arg))
96 yield return false;
97 }
98 }
99
100 public override string ToString()
101 {
102 object value = getValue();
103 if (value == this)
104 return "Variable";
105 else
106 return getValue().ToString();
107 }
108
109 /// <summary>
110 /// If bound, call YP.addUniqueVariables on the value. Otherwise, if this unbound
111 /// variable is not already in variableSet, add it.
112 /// </summary>
113 /// <param name="variableSet"></param>
114 public void addUniqueVariables(List<Variable> variableSet)
115 {
116 if (_isBound)
117 YP.addUniqueVariables(getValue(), variableSet);
118 else
119 {
120 if (variableSet.IndexOf(this) < 0)
121 variableSet.Add(this);
122 }
123 }
124
125 /// <summary>
126 /// If bound, return YP.makeCopy for the value, else return copyStore.getCopy(this).
127 /// However, if copyStore is null, just return this.
128 /// </summary>
129 /// <param name="copyStore"></param>
130 /// <returns></returns>
131 public object makeCopy(Variable.CopyStore copyStore)
132 {
133 if (_isBound)
134 return YP.makeCopy(getValue(), copyStore);
135 else
136 return copyStore == null ? this : copyStore.getCopy(this);
137 }
138
139 public bool termEqual(object term)
140 {
141 if (_isBound)
142 return YP.termEqual(getValue(), term);
143 else
144 return this == YP.getValue(term);
145 }
146
147 public bool ground()
148 {
149 if (_isBound)
150 // This is usually called by YP.ground which already did getValue, so this
151 // should never be reached, but check anyway.
152 return YP.ground(getValue());
153 else
154 return false;
155 }
156
157 /// <summary>
158 /// A CopyStore is used by makeCopy to track which Variable objects have
159 /// been copied.
160 /// </summary>
161 public class CopyStore
162 {
163 private List<Variable> _inVariableSet = new List<Variable>();
164 private List<Variable> _outVariableSet = new List<Variable>();
165
166 /// <summary>
167 /// If inVariable has already been copied, return its copy. Otherwise,
168 /// return a fresh Variable associated with inVariable.
169 /// </summary>
170 /// <param name="inVariable"></param>
171 /// <returns></returns>
172 public Variable getCopy(Variable inVariable)
173 {
174 int index = _inVariableSet.IndexOf(inVariable);
175 if (index >= 0)
176 return _outVariableSet[index];
177 else
178 {
179 Variable outVariable = new Variable();
180 _inVariableSet.Add(inVariable);
181 _outVariableSet.Add(outVariable);
182 return outVariable;
183 }
184 }
185
186 /// <summary>
187 /// Return the number of unique variables that have been copied.
188 /// </summary>
189 /// <returns></returns>
190 public int getNUniqueVariables()
191 {
192 return _inVariableSet.Count;
193 }
194 }
195 }
196}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
new file mode 100644
index 0000000..74704aa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
@@ -0,0 +1,1644 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34using System.IO;
35using System.Reflection;
36
37namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
38{
39 /// <summary>
40 /// YP has static methods for general functions in Yield Prolog such as <see cref="getValue"/>
41 /// and <see cref="unify"/>.
42 /// </summary>
43 public class YP
44 {
45 private static Fail _fail = new Fail();
46 private static Repeat _repeat = new Repeat();
47 private static Dictionary<NameArity, List<IClause>> _predicatesStore =
48 new Dictionary<NameArity, List<IClause>>();
49 private static TextWriter _outputStream = System.Console.Out;
50 private static TextReader _inputStream = System.Console.In;
51 private static List<object[]> _operatorTable = null;
52
53 /// <summary>
54 /// An IClause is used so that dynamic predicates can call match.
55 /// </summary>
56 public interface IClause
57 {
58 IEnumerable<bool> match(object[] args);
59 }
60
61 public static object getValue(object value)
62 {
63 if (value is Variable)
64 return ((Variable)value).getValue();
65 else
66 return value;
67 }
68
69 public static IEnumerable<bool> unify(object arg1, object arg2)
70 {
71 arg1 = getValue(arg1);
72 arg2 = getValue(arg2);
73 if (arg1 is IUnifiable)
74 return ((IUnifiable)arg1).unify(arg2);
75 else if (arg2 is IUnifiable)
76 return ((IUnifiable)arg2).unify(arg1);
77 else
78 {
79 // Arguments are "normal" types.
80 if (arg1.Equals(arg2))
81 return new Succeed();
82 else
83 return _fail;
84 }
85 }
86
87 /// <summary>
88 /// This is used for the lookup key in _factStore.
89 /// </summary>
90 public struct NameArity
91 {
92 public readonly Atom _name;
93 public readonly int _arity;
94
95 public NameArity(Atom name, int arity)
96 {
97 _name = name;
98 _arity = arity;
99 }
100
101 public override bool Equals(object obj)
102 {
103 if (obj is NameArity)
104 {
105 NameArity nameArity = (NameArity)obj;
106 return nameArity._name.Equals(_name) && nameArity._arity.Equals(_arity);
107 }
108 else
109 {
110 return false;
111 }
112 }
113
114 public override int GetHashCode()
115 {
116 return _name.GetHashCode() ^ _arity.GetHashCode();
117 }
118 }
119
120 /// <summary>
121 /// Convert term to an int.
122 /// If term is a single-element List, use its first element
123 /// (to handle the char types like "a"). If can't convert, throw an exception.
124 /// </summary>
125 /// <param name="term"></param>
126 /// <returns></returns>
127 public static int convertInt(object term)
128 {
129 term = YP.getValue(term);
130 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
131 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
132 // Assume it is a char type like "a".
133 term = YP.getValue(((Functor2)term)._arg1);
134
135 return (int)term;
136 }
137
138 /// <summary>
139 /// Convert term to a double. This may convert an int to a double, etc.
140 /// If term is a single-element List, use its first element
141 /// (to handle the char types like "a"). If can't convert, throw an exception.
142 /// </summary>
143 /// <param name="term"></param>
144 /// <returns></returns>
145 public static double convertDouble(object term)
146 {
147 term = YP.getValue(term);
148 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
149 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
150 // Assume it is a char type like "a".
151 term = YP.getValue(((Functor2)term)._arg1);
152 if (term is Variable)
153 throw new PrologException(Atom.a("instantiation_error"),
154 "Expected a number but the argument is an unbound variable");
155
156 return Convert.ToDouble(term);
157 }
158
159 /// <summary>
160 /// If term is an integer, set intTerm.
161 /// If term is a single-element List, use its first element
162 /// (to handle the char types like "a"). Return true for success, false if can't convert.
163 /// We use a success return value because throwing an exception is inefficient.
164 /// </summary>
165 /// <param name="term"></param>
166 /// <returns></returns>
167 public static bool getInt(object term, out int intTerm)
168 {
169 term = YP.getValue(term);
170 if (term is Functor2 && ((Functor2)term)._name == Atom.DOT &&
171 YP.getValue(((Functor2)term)._arg2) == Atom.NIL)
172 // Assume it is a char type like "a".
173 term = YP.getValue(((Functor2)term)._arg1);
174
175 if (term is int)
176 {
177 intTerm = (int)term;
178 return true;
179 }
180
181 intTerm = 0;
182 return false;
183 }
184
185 public static bool equal(object x, object y)
186 {
187 x = YP.getValue(x);
188 if (x is DateTime)
189 return (DateTime)x == (DateTime)YP.getValue(y);
190 // Assume convertDouble converts an int to a double perfectly.
191 return YP.convertDouble(x) == YP.convertDouble(y);
192 }
193
194 public static bool notEqual(object x, object y)
195 {
196 x = YP.getValue(x);
197 if (x is DateTime)
198 return (DateTime)x != (DateTime)YP.getValue(y);
199 // Assume convertDouble converts an int to a double perfectly.
200 return YP.convertDouble(x) != YP.convertDouble(y);
201 }
202
203 public static bool greaterThan(object x, object y)
204 {
205 x = YP.getValue(x);
206 if (x is DateTime)
207 return (DateTime)x > (DateTime)YP.getValue(y);
208 // Assume convertDouble converts an int to a double perfectly.
209 return YP.convertDouble(x) > YP.convertDouble(y);
210 }
211
212 public static bool lessThan(object x, object y)
213 {
214 x = YP.getValue(x);
215 if (x is DateTime)
216 return (DateTime)x < (DateTime)YP.getValue(y);
217 // Assume convertDouble converts an int to a double perfectly.
218 return YP.convertDouble(x) < YP.convertDouble(y);
219 }
220
221 public static bool greaterThanOrEqual(object x, object y)
222 {
223 x = YP.getValue(x);
224 if (x is DateTime)
225 return (DateTime)x >= (DateTime)YP.getValue(y);
226 // Assume convertDouble converts an int to a double perfectly.
227 return YP.convertDouble(x) >= YP.convertDouble(y);
228 }
229
230 public static bool lessThanOrEqual(object x, object y)
231 {
232 x = YP.getValue(x);
233 if (x is DateTime)
234 return (DateTime)x <= (DateTime)YP.getValue(y);
235 // Assume convertDouble converts an int to a double perfectly.
236 return YP.convertDouble(x) <= YP.convertDouble(y);
237 }
238
239 public static object negate(object x)
240 {
241 int intX;
242 if (getInt(x, out intX))
243 return -intX;
244 return -convertDouble(x);
245 }
246
247 public static object abs(object x)
248 {
249 int intX;
250 if (getInt(x, out intX))
251 return Math.Abs(intX);
252 return Math.Abs(convertDouble(x));
253 }
254
255 public static object sign(object x)
256 {
257 int intX;
258 if (getInt(x, out intX))
259 return Math.Sign(intX);
260 return Math.Sign(convertDouble(x));
261 }
262
263 /// <summary>
264 /// The ISO standard returns an int.
265 /// </summary>
266 /// <param name="x"></param>
267 /// <returns></returns>
268 public static object floor(object x)
269 {
270 return (int)Math.Floor(convertDouble(x));
271 }
272
273 /// <summary>
274 /// The ISO standard returns an int.
275 /// </summary>
276 /// <param name="x"></param>
277 /// <returns></returns>
278 public static object truncate(object x)
279 {
280 return (int)Math.Truncate(convertDouble(x));
281 }
282
283 /// <summary>
284 /// The ISO standard returns an int.
285 /// </summary>
286 /// <param name="x"></param>
287 /// <returns></returns>
288 public static object round(object x)
289 {
290 return (int)Math.Round(convertDouble(x));
291 }
292
293 /// <summary>
294 /// The ISO standard returns an int.
295 /// </summary>
296 /// <param name="x"></param>
297 /// <returns></returns>
298 public static object ceiling(object x)
299 {
300 return (int)Math.Ceiling(convertDouble(x));
301 }
302
303 public static object sin(object x)
304 {
305 return Math.Sin(YP.convertDouble(x));
306 }
307
308 public static object cos(object x)
309 {
310 return Math.Cos(YP.convertDouble(x));
311 }
312
313 public static object atan(object x)
314 {
315 return Math.Atan(YP.convertDouble(x));
316 }
317
318 public static object exp(object x)
319 {
320 return Math.Exp(YP.convertDouble(x));
321 }
322
323 public static object log(object x)
324 {
325 return Math.Log(YP.convertDouble(x));
326 }
327
328 public static object sqrt(object x)
329 {
330 return Math.Sqrt(convertDouble(x));
331 }
332
333 public static object bitwiseComplement(object x)
334 {
335 return ~YP.convertInt(x);
336 }
337
338 public static object add(object x, object y)
339 {
340 int intX, intY;
341 if (getInt(x, out intX) && getInt(y, out intY))
342 return intX + intY;
343 return convertDouble(x) + convertDouble(y);
344 }
345
346 public static object subtract(object x, object y)
347 {
348 int intX, intY;
349 if (getInt(x, out intX) && getInt(y, out intY))
350 return intX - intY;
351 return convertDouble(x) - convertDouble(y);
352 }
353
354 public static object multiply(object x, object y)
355 {
356 int intX, intY;
357 if (getInt(x, out intX) && getInt(y, out intY))
358 return intX * intY;
359 return convertDouble(x) * convertDouble(y);
360 }
361
362 /// <summary>
363 /// Return floating point, even if both arguments are integer.
364 /// </summary>
365 /// <param name="x"></param>
366 /// <param name="y"></param>
367 /// <returns></returns>
368 public static object divide(object x, object y)
369 {
370 return convertDouble(x) / convertDouble(y);
371 }
372
373 public static object intDivide(object x, object y)
374 {
375 int intX, intY;
376 if (getInt(x, out intX) && getInt(y, out intY))
377 return intX / intY;
378 // Still allow passing a double, but treat as an int.
379 return (int)convertDouble(x) / (int)convertDouble(y);
380 }
381
382 public static object mod(object x, object y)
383 {
384 int intX, intY;
385 if (getInt(x, out intX) && getInt(y, out intY))
386 return intX % intY;
387 // Still allow passing a double, but treat as an int.
388 return (int)convertDouble(x) % (int)convertDouble(y);
389 }
390
391 public static object pow(object x, object y)
392 {
393 return Math.Pow(YP.convertDouble(x), YP.convertDouble(y));
394 }
395
396 public static object bitwiseShiftRight(object x, object y)
397 {
398 return YP.convertInt(x) >> YP.convertInt(y);
399 }
400
401 public static object bitwiseShiftLeft(object x, object y)
402 {
403 return YP.convertInt(x) << YP.convertInt(y);
404 }
405
406 public static object bitwiseAnd(object x, object y)
407 {
408 return YP.convertInt(x) & YP.convertInt(y);
409 }
410
411 public static object bitwiseOr(object x, object y)
412 {
413 return YP.convertInt(x) | YP.convertInt(y);
414 }
415
416 public static object min(object x, object y)
417 {
418 int intX, intY;
419 if (getInt(x, out intX) && getInt(y, out intY))
420 return Math.Min(intX, intY);
421 return Math.Min(convertDouble(x), convertDouble(y));
422 }
423
424 public static object max(object x, object y)
425 {
426 int intX, intY;
427 if (getInt(x, out intX) && getInt(y, out intY))
428 return Math.Max(intX, intY);
429 return Math.Max(convertDouble(x), convertDouble(y));
430 }
431
432 public static IEnumerable<bool> copy_term(object inTerm, object outTerm)
433 {
434 return YP.unify(outTerm, YP.makeCopy(inTerm, new Variable.CopyStore()));
435 }
436
437 public static void addUniqueVariables(object term, List<Variable> variableSet)
438 {
439 term = YP.getValue(term);
440 if (term is IUnifiable)
441 ((IUnifiable)term).addUniqueVariables(variableSet);
442 }
443
444 public static object makeCopy(object term, Variable.CopyStore copyStore)
445 {
446 term = YP.getValue(term);
447 if (term is IUnifiable)
448 return ((IUnifiable)term).makeCopy(copyStore);
449 else
450 // term is a "normal" type. Assume it is ground.
451 return term;
452 }
453
454 /// <summary>
455 /// Sort the array in place according to termLessThan. This does not remove duplicates
456 /// </summary>
457 /// <param name="array"></param>
458 public static void sortArray(object[] array)
459 {
460 Array.Sort(array, YP.compareTerms);
461 }
462
463 /// <summary>
464 /// Sort the array in place according to termLessThan. This does not remove duplicates
465 /// </summary>
466 /// <param name="array"></param>
467 public static void sortArray(List<object> array)
468 {
469 array.Sort(YP.compareTerms);
470 }
471
472 /// <summary>
473 /// Sort List according to termLessThan, remove duplicates and unify with Sorted.
474 /// </summary>
475 /// <param name="List"></param>
476 /// <param name="Sorted"></param>
477 /// <returns></returns>
478 public static IEnumerable<bool> sort(object List, object Sorted)
479 {
480 object[] array = ListPair.toArray(List);
481 if (array == null)
482 return YP.fail();
483 if (array.Length > 1)
484 sortArray(array);
485 return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
486 }
487
488
489
490 /// <summary>
491 /// Use YP.unify to unify each of the elements of the two arrays, and yield
492 /// once if they all unify.
493 /// </summary>
494 /// <param name="array1"></param>
495 /// <param name="array2"></param>
496 /// <returns></returns>
497 public static IEnumerable<bool> unifyArrays(object[] array1, object[] array2)
498 {
499 if (array1.Length != array2.Length)
500 yield break;
501
502 IEnumerator<bool>[] iterators = new IEnumerator<bool>[array1.Length];
503 bool gotMatch = true;
504 int nIterators = 0;
505 // Try to bind all the arguments.
506 for (int i = 0; i < array1.Length; ++i)
507 {
508 IEnumerator<bool> iterator = YP.unify(array1[i], array2[i]).GetEnumerator();
509 iterators[nIterators++] = iterator;
510 // MoveNext() is true if YP.unify succeeds.
511 if (!iterator.MoveNext())
512 {
513 gotMatch = false;
514 break;
515 }
516 }
517
518 try
519 {
520 if (gotMatch)
521 yield return false;
522 }
523 finally
524 {
525 // Manually finalize all the iterators.
526 for (int i = 0; i < nIterators; ++i)
527 iterators[i].Dispose();
528 }
529 }
530
531 /// <summary>
532 /// Return an iterator (which you can use in a for-in loop) which does
533 /// zero iterations. This returns a pre-existing iterator which is
534 /// more efficient than letting the compiler generate a new one.
535 /// </summary>
536 /// <returns></returns>
537 public static IEnumerable<bool> fail()
538 {
539 return _fail;
540 }
541
542 /// <summary>
543 /// Return an iterator (which you can use in a for-in loop) which does
544 /// one iteration. This returns a pre-existing iterator which is
545 /// more efficient than letting the compiler generate a new one.
546 /// </summary>
547 /// <returns></returns>
548 public static IEnumerable<bool> succeed()
549 {
550 return new Succeed();
551 }
552
553 /// <summary>
554 /// Return an iterator (which you can use in a for-in loop) which repeats
555 /// indefinitely. This returns a pre-existing iterator which is
556 /// more efficient than letting the compiler generate a new one.
557 /// </summary>
558 /// <returns></returns>
559 public static IEnumerable<bool> repeat()
560 {
561 return _repeat;
562 }
563
564 public static IEnumerable<bool> univ(object Term, object List)
565 {
566 Term = YP.getValue(Term);
567 List = YP.getValue(List);
568
569 if (nonvar(Term))
570 return YP.unify(new ListPair
571 (getFunctorName(Term), ListPair.make(getFunctorArgs(Term))), List);
572
573 Variable Name = new Variable();
574 Variable ArgList = new Variable();
575 foreach (bool l1 in new ListPair(Name, ArgList).unify(List))
576 {
577 object[] args = ListPair.toArray(ArgList);
578 if (args == null)
579 throw new Exception("Expected a list. Got: " + ArgList.getValue());
580 if (args.Length == 0)
581 // Return the Name, even if it is not an Atom.
582 return YP.unify(Term, Name);
583 if (!atom(Name))
584 throw new Exception("Expected an atom. Got: " + Name.getValue());
585
586 return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args));
587 }
588
589 return YP.fail();
590 }
591
592 public static IEnumerable<bool> functor(object Term, object FunctorName, object Arity)
593 {
594 Term = YP.getValue(Term);
595 FunctorName = YP.getValue(FunctorName);
596 Arity = YP.getValue(Arity);
597
598 if (!(Term is Variable))
599 {
600 foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term)))
601 {
602 foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length))
603 yield return false;
604 }
605 }
606 else
607 throw new NotImplementedException("Debug: must finish functor/3");
608 }
609
610 public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value)
611 {
612 if (YP.var(ArgNumber))
613 throw new NotImplementedException("Debug: must finish arg/3");
614 else
615 {
616 int argNumberInt = convertInt(ArgNumber);
617 if (argNumberInt < 0)
618 throw new Exception("ArgNumber must be non-negative");
619 object[] termArgs = YP.getFunctorArgs(Term);
620 // Silently fail if argNumberInt is out of range.
621 if (argNumberInt >= 1 && argNumberInt <= termArgs.Length)
622 {
623 // The first ArgNumber is at 1, not 0.
624 foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1]))
625 yield return false;
626 }
627 }
628 }
629
630 public static bool termEqual(object Term1, object Term2)
631 {
632 Term1 = YP.getValue(Term1);
633 if (Term1 is IUnifiable)
634 return ((IUnifiable)Term1).termEqual(Term2);
635 return Term1.Equals(YP.getValue(Term2));
636 }
637
638 public static bool termNotEqual(object Term1, object Term2)
639 {
640 return !termEqual(Term1, Term2);
641 }
642
643 public static bool termLessThan(object Term1, object Term2)
644 {
645 Term1 = YP.getValue(Term1);
646 Term2 = YP.getValue(Term2);
647 int term1TypeCode = getTypeCode(Term1);
648 int term2TypeCode = getTypeCode(Term2);
649 if (term1TypeCode != term2TypeCode)
650 return term1TypeCode < term2TypeCode;
651
652 // The terms are the same type code.
653 if (term1TypeCode == -2)
654 {
655 // Variable.
656 // We always check for equality first because we want to be sure
657 // that less than returns false if the terms are equal, in
658 // case that the less than check really behaves like less than or equal.
659 if ((Variable)Term1 != (Variable)Term2)
660 // The hash code should be unique to a Variable object.
661 return Term1.GetHashCode() < Term2.GetHashCode();
662 return false;
663 }
664 if (term1TypeCode == 0)
665 return ((Atom)Term1)._name.CompareTo(((Atom)Term2)._name) < 0;
666 if (term1TypeCode == 1)
667 return ((Functor1)Term1).lessThan((Functor1)Term2);
668 if (term1TypeCode == 2)
669 return ((Functor2)Term1).lessThan((Functor2)Term2);
670 if (term1TypeCode == 3)
671 return ((Functor3)Term1).lessThan((Functor3)Term2);
672 if (term1TypeCode == 4)
673 return ((Functor)Term1).lessThan((Functor)Term2);
674
675 // Type code is -1 for general objects. First compare their type names.
676 // Note that this puts Double before Int32 as required by ISO Prolog.
677 string term1TypeName = Term1.GetType().ToString();
678 string term2TypeName = Term2.GetType().ToString();
679 if (term1TypeName != term2TypeName)
680 return term1TypeName.CompareTo(term2TypeName) < 0;
681
682 // The terms are the same type name.
683 if (Term1 is int)
684 return (int)Term1 < (int)Term2;
685 else if (Term1 is double)
686 return (double)Term1 < (double)Term2;
687 else if (Term1 is DateTime)
688 return (DateTime)Term1 < (DateTime)Term2;
689 else if (Term1 is String)
690 return ((String)Term1).CompareTo((String)Term2) < 0;
691 // Debug: Should we try arrays, etc.?
692
693 if (!Term1.Equals(Term2))
694 // Could be equal or greater than.
695 return Term1.GetHashCode() < Term2.GetHashCode();
696 return false;
697 }
698
699 /// <summary>
700 /// Type code is -2 if term is a Variable, 0 if it is an Atom,
701 /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3,
702 /// 4 if it is Functor.
703 /// Otherwise, type code is -1.
704 /// This does not call YP.getValue(term).
705 /// </summary>
706 /// <param name="term"></param>
707 /// <returns></returns>
708 private static int getTypeCode(object term)
709 {
710 if (term is Variable)
711 return -2;
712 else if (term is Atom)
713 return 0;
714 else if (term is Functor1)
715 return 1;
716 else if (term is Functor2)
717 return 2;
718 else if (term is Functor3)
719 return 3;
720 else if (term is Functor)
721 return 4;
722 else
723 return -1;
724 }
725
726 public static bool termLessThanOrEqual(object Term1, object Term2)
727 {
728 if (YP.termEqual(Term1, Term2))
729 return true;
730 return YP.termLessThan(Term1, Term2);
731 }
732
733 public static bool termGreaterThan(object Term1, object Term2)
734 {
735 return !YP.termLessThanOrEqual(Term1, Term2);
736 }
737
738 public static bool termGreaterThanOrEqual(object Term1, object Term2)
739 {
740 // termLessThan should ensure that it returns false if terms are equal,
741 // so that this would return true.
742 return !YP.termLessThan(Term1, Term2);
743 }
744
745 public static int compareTerms(object Term1, object Term2)
746 {
747 if (YP.termEqual(Term1, Term2))
748 return 0;
749 else if (YP.termLessThan(Term1, Term2))
750 return -1;
751 else
752 return 1;
753 }
754
755 public static bool ground(object Term)
756 {
757 Term = YP.getValue(Term);
758 if (Term is IUnifiable)
759 return ((IUnifiable)Term).ground();
760 return true;
761 }
762
763 public static IEnumerable<bool> current_op
764 (object Priority, object Specifier, object Operator)
765 {
766 if (_operatorTable == null)
767 {
768 // Initialize.
769 _operatorTable = new List<object[]>();
770 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") });
771 _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") });
772 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") });
773 _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") });
774 _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") });
775 _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") });
776 _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") });
777 _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") });
778 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") });
779 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") });
780 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") });
781 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") });
782 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") });
783 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") });
784 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") });
785 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") });
786 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") });
787 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") });
788 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") });
789 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") });
790 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") });
791 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") });
792 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") });
793 _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") });
794 _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") });
795 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") });
796 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") });
797 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") });
798 _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") });
799 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") });
800 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") });
801 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") });
802 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") });
803 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") });
804 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") });
805 _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") });
806 _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") });
807 _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") });
808 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") });
809 _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") });
810 // Debug: This is hacked in to run the Prolog test suite until we implement op/3.
811 _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
812 }
813
814 object[] args = new object[] { Priority, Specifier, Operator };
815 foreach (object[] answer in _operatorTable)
816 {
817 foreach (bool l1 in YP.unifyArrays(args, answer))
818 yield return false;
819 }
820 }
821
822 public static IEnumerable<bool> atom_length(object atom, object Length)
823 {
824 return YP.unify(Length, ((Atom)YP.getValue(atom))._name.Length);
825 }
826
827 public static IEnumerable<bool> atom_concat(object Start, object End, object Whole)
828 {
829 // Debug: Should implement for var(Start) which is a kind of search.
830 // Debug: Should we try to preserve the _declaringClass?
831 return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name +
832 ((Atom)YP.getValue(End))._name));
833 }
834
835 public static IEnumerable<bool> sub_atom
836 (object atom, object Before, object Length, object After, object Sub_atom)
837 {
838 // Debug: Should implement for var(atom) which is a kind of search.
839 // Debug: Should we try to preserve the _declaringClass?
840 Atom atomAtom = (Atom)YP.getValue(atom);
841 int beforeInt = YP.convertInt(Before);
842 int lengthInt = YP.convertInt(Length);
843 if (beforeInt < 0)
844 throw new Exception("Before must be non-negative");
845 if (lengthInt < 0)
846 throw new Exception("Length must be non-negative");
847 int afterInt = atomAtom._name.Length - (beforeInt + lengthInt);
848 if (afterInt >= 0)
849 {
850 foreach (bool l1 in YP.unify(After, afterInt))
851 {
852 foreach (bool l2 in YP.unify
853 (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt))))
854 yield return false;
855 }
856 }
857 }
858
859 public static IEnumerable<bool> atom_codes(object atom, object List)
860 {
861 atom = YP.getValue(atom);
862 List = YP.getValue(List);
863
864 if (nonvar(atom))
865 {
866 string name = ((Atom)atom)._name;
867 object codeList = Atom.NIL;
868 // Start from the back to make the list.
869 for (int i = name.Length - 1; i >= 0; --i)
870 codeList = new ListPair((int)name[i], codeList);
871 return YP.unify(List, codeList);
872 }
873 {
874 object[] codeArray = ListPair.toArray(List);
875 char[] charArray = new char[codeArray.Length];
876 for (int i = 0; i < codeArray.Length; ++i)
877 charArray[i] = (char)YP.convertInt(codeArray[i]);
878 return YP.unify(atom, Atom.a(new String(charArray)));
879 }
880 }
881
882 public static IEnumerable<bool> number_codes(object number, object List)
883 {
884 number = YP.getValue(number);
885 List = YP.getValue(List);
886
887 if (nonvar(number))
888 {
889 string numberString = null;
890 // Try converting to an int first.
891 int intNumber;
892 if (YP.getInt(number, out intNumber))
893 numberString = intNumber.ToString();
894 else
895 numberString = YP.doubleToString(YP.convertDouble(number));
896
897 object codeList = Atom.NIL;
898 // Start from the back to make the list.
899 for (int i = numberString.Length - 1; i >= 0; --i)
900 codeList = new ListPair((int)numberString[i], codeList);
901 return YP.unify(List, codeList);
902 }
903 {
904 object[] codeArray = ListPair.toArray(List);
905 char[] charArray = new char[codeArray.Length];
906 for (int i = 0; i < codeArray.Length; ++i)
907 charArray[i] = (char)YP.convertInt(codeArray[i]);
908 String numberString = new String(charArray);
909 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
910 try
911 {
912 // Try an int first.
913 return YP.unify(number, Convert.ToInt32(numberString));
914 }
915 catch (FormatException) { }
916 return YP.unify(number, Convert.ToDouble(numberString));
917 }
918 }
919
920 /// <summary>
921 /// If term is an Atom or functor type, return its name.
922 /// Otherwise, return term.
923 /// </summary>
924 /// <param name="term"></param>
925 /// <returns></returns>
926 public static object getFunctorName(object term)
927 {
928 term = YP.getValue(term);
929 if (term is Functor1)
930 return ((Functor1)term)._name;
931 else if (term is Functor2)
932 return ((Functor2)term)._name;
933 else if (term is Functor3)
934 return ((Functor3)term)._name;
935 else if (term is Functor)
936 return ((Functor)term)._name;
937 else
938 return term;
939 }
940
941 /// <summary>
942 /// If term is an Atom or functor type, return an array of its args.
943 /// Otherwise, return an empty array.
944 /// </summary>
945 /// <param name="term"></param>
946 /// <returns></returns>
947 public static object[] getFunctorArgs(object term)
948 {
949 term = YP.getValue(term);
950 if (term is Functor1)
951 {
952 Functor1 functor = (Functor1)term;
953 return new object[] { functor._arg1 };
954 }
955 else if (term is Functor2)
956 {
957 Functor2 functor = (Functor2)term;
958 return new object[] { functor._arg1, functor._arg2 };
959 }
960 else if (term is Functor3)
961 {
962 Functor3 functor = (Functor3)term;
963 return new object[] { functor._arg1, functor._arg2, functor._arg3 };
964 }
965 else if (term is Functor) {
966 Functor functor = (Functor)term;
967 return functor._args;
968 }
969 else
970 return new object[0];
971 }
972
973 public static bool var(object Term)
974 {
975 return YP.getValue(Term) is Variable;
976 }
977
978 public static bool nonvar(object Term)
979 {
980 return !YP.var(Term);
981 }
982
983 public static bool atom(object Term)
984 {
985 return YP.getValue(Term) is Atom;
986 }
987
988 public static bool integer(object Term)
989 {
990 // Debug: Should exhaustively check for all integer types.
991 return getValue(Term) is int;
992 }
993
994 // Use isFloat instead of float because it is a reserved keyword.
995 public static bool isFloat(object Term)
996 {
997 // Debug: Should exhaustively check for all float types.
998 return getValue(Term) is double;
999 }
1000
1001 public static bool number(object Term)
1002 {
1003 return YP.integer(Term) || YP.isFloat(Term);
1004 }
1005
1006 public static bool atomic(object Term)
1007 {
1008 return YP.atom(Term) || YP.number(Term);
1009 }
1010
1011 public static bool compound(object Term)
1012 {
1013 Term = getValue(Term);
1014 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor;
1015 }
1016
1017 public static void see(object input)
1018 {
1019 input = YP.getValue(input);
1020 if (input is TextReader)
1021 {
1022 _inputStream = (TextReader)input;
1023 return;
1024 }
1025 else if (input is Atom)
1026 {
1027 _inputStream = new StreamReader(((Atom)input)._name);
1028 return;
1029 }
1030 else if (input is String)
1031 {
1032 _inputStream = new StreamReader((String)input);
1033 return;
1034 }
1035 else
1036 throw new InvalidOperationException("Can't open stream for " + input);
1037 }
1038
1039 public static void seen()
1040 {
1041 if (_inputStream == Console.In)
1042 return;
1043 _inputStream.Close();
1044 _inputStream = Console.In;
1045 }
1046
1047 public static void tell(object output)
1048 {
1049 output = YP.getValue(output);
1050 if (output is TextWriter)
1051 {
1052 _outputStream = (TextWriter)output;
1053 return;
1054 }
1055 else if (output is Atom)
1056 {
1057 _outputStream = new StreamWriter(((Atom)output)._name);
1058 return;
1059 }
1060 else if (output is String)
1061 {
1062 _outputStream = new StreamWriter((String)output);
1063 return;
1064 }
1065 else
1066 throw new InvalidOperationException("Can't open stream for " + output);
1067 }
1068
1069 public static void told()
1070 {
1071 if (_outputStream == Console.Out)
1072 return;
1073 _outputStream.Close();
1074 _outputStream = Console.Out;
1075 }
1076
1077 public static IEnumerable<bool> current_output(object Stream)
1078 {
1079 return YP.unify(Stream, _outputStream);
1080 }
1081
1082 public static void write(object x)
1083 {
1084 x = YP.getValue(x);
1085 if (x is double)
1086 _outputStream.Write(doubleToString((double)x));
1087 else
1088 _outputStream.Write(x.ToString());
1089 }
1090
1091 /// <summary>
1092 /// Format x as a string, making sure that it will parse as an int later. I.e., for 1.0, don't just
1093 /// use "1" which will parse as an int.
1094 /// </summary>
1095 /// <param name="x"></param>
1096 /// <returns></returns>
1097 private static string doubleToString(double x)
1098 {
1099 string xString = x.ToString();
1100 // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception?
1101 try
1102 {
1103 Convert.ToInt32(xString);
1104 // The string will parse as an int, not a double, so re-format so that it does.
1105 // Use float if possible, else exponential if it would be too big.
1106 return x.ToString(x >= 100000.0 ? "E1" : "f1");
1107 }
1108 catch (FormatException)
1109 {
1110 // Assume it will parse as a double.
1111 }
1112 return xString;
1113 }
1114
1115 public static void put_code(object x)
1116 {
1117 _outputStream.Write((char)YP.convertInt(x));
1118 }
1119
1120 public static void nl()
1121 {
1122 _outputStream.WriteLine();
1123 }
1124
1125 public static IEnumerable<bool> get_code(object code)
1126 {
1127 return YP.unify(code, _inputStream.Read());
1128 }
1129
1130 public static void asserta(object Term, Type declaringClass)
1131 {
1132 assertDynamic(Term, declaringClass, true);
1133 }
1134
1135 public static void assertz(object Term, Type declaringClass)
1136 {
1137 assertDynamic(Term, declaringClass, false);
1138 }
1139
1140 public static void assertDynamic(object Term, Type declaringClass, bool prepend)
1141 {
1142 Term = getValue(Term);
1143 if (Term is Variable)
1144 throw new PrologException("instantiation_error", "Term to assert is an unbound variable");
1145
1146 Variable.CopyStore copyStore = new Variable.CopyStore();
1147 object TermCopy = makeCopy(Term, copyStore);
1148 object Head, Body;
1149 if (TermCopy is Functor2 && ((Functor2)TermCopy)._name == Atom.RULE)
1150 {
1151 Head = YP.getValue(((Functor2)TermCopy)._arg1);
1152 Body = YP.getValue(((Functor2)TermCopy)._arg2);
1153 }
1154 else
1155 {
1156 Head = TermCopy;
1157 Body = Atom.a("true");
1158 }
1159
1160 Atom name = getFunctorName(Head) as Atom;
1161 if (name == null)
1162 // name is a non-Atom, such as a number.
1163 throw new PrologException
1164 (new Functor2("type_error", Atom.a("callable"), Head), "Term to assert is not callable");
1165 object[] args = getFunctorArgs(Head);
1166 if (!isDynamic(name, args.Length))
1167 throw new PrologException
1168 (new Functor3("permission_error", Atom.a("modify"), Atom.a("static_procedure"),
1169 new Functor2(Atom.SLASH, name, args.Length)),
1170 "Assert cannot modify static predicate " + name + "/" + args.Length);
1171
1172 if (copyStore.getNUniqueVariables() == 0 && Body == Atom.a("true"))
1173 {
1174 // Debug: Until IndexedAnswers supports prepend, compile the fact so we can prepend it below.
1175 if (!prepend)
1176 {
1177 // This is a fact with no unbound variables
1178 // assertFact uses IndexedAnswers, so don't we don't need to compile.
1179 assertFact(name, args);
1180 return;
1181 }
1182 }
1183
1184 IClause clause = YPCompiler.compileAnonymousClause(Head, Body, declaringClass);
1185
1186 // Add the clause to the entry in _predicatesStore.
1187 NameArity nameArity = new NameArity(name, args.Length);
1188 List<IClause> clauses;
1189 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1190 // Create an entry for the nameArity.
1191 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1192
1193 if (prepend)
1194 clauses.Insert(0, clause);
1195 else
1196 clauses.Add(clause);
1197 }
1198
1199 private static bool isDynamic(Atom name, int arity)
1200 {
1201 if (arity == 2 && (name == Atom.a(",") || name == Atom.a(";") || name == Atom.DOT))
1202 return false;
1203 // Use the same mapping to static predicates in YP as the compiler.
1204 foreach (bool l1 in YPCompiler.functorCallYPFunctionName(name, arity, new Variable()))
1205 return false;
1206 // Debug: Do we need to check if name._module is null?
1207 return true;
1208 }
1209
1210 /// <summary>
1211 /// Assert values at the end of the set of facts for the predicate with the
1212 /// name and with arity values.Length.
1213 /// </summary>
1214 /// <param name="name">must be an Atom</param>
1215 /// <param name="values">the array of arguments to the fact predicate.
1216 /// It is an error if an value has an unbound variable.</param>
1217 public static void assertFact(Atom name, object[] values)
1218 {
1219 NameArity nameArity = new NameArity(name, values.Length);
1220 List<IClause> clauses;
1221 IndexedAnswers indexedAnswers;
1222 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1223 {
1224 // Create an IndexedAnswers as the first clause of the predicate.
1225 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1226 clauses.Add(indexedAnswers = new IndexedAnswers());
1227 }
1228 else
1229 {
1230 indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers;
1231 if (indexedAnswers == null)
1232 // The latest clause is not an IndexedAnswers, so add one.
1233 clauses.Add(indexedAnswers = new IndexedAnswers());
1234 }
1235
1236 indexedAnswers.addAnswer(values);
1237 }
1238
1239 /// <summary>
1240 /// Match all clauses of the dynamic predicate with the name and with arity
1241 /// arguments.Length.
1242 /// It is an error if the predicate is not defined.
1243 /// </summary>
1244 /// <param name="name">must be an Atom</param>
1245 /// <param name="arguments">an array of arity number of arguments</param>
1246 /// <returns>an iterator which you can use in foreach</returns>
1247 public static IEnumerable<bool> matchDynamic(Atom name, object[] arguments)
1248 {
1249 List<IClause> clauses;
1250 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1251 throw new UndefinedPredicateException
1252 ("Undefined fact: " + name + "/" + arguments.Length, name,
1253 arguments.Length);
1254
1255 if (clauses.Count == 1)
1256 // Usually there is only one clause, so return it without needing to wrap it in an iterator.
1257 return clauses[0].match(arguments);
1258 else
1259 return matchAllClauses(clauses, arguments);
1260 }
1261
1262 /// <summary>
1263 /// Call match(arguments) for each IClause in clauses. We make this a separate
1264 /// function so that matchDynamic itself does not need to be an iterator object.
1265 /// </summary>
1266 /// <param name="clauses"></param>
1267 /// <param name="arguments"></param>
1268 /// <returns></returns>
1269 private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments)
1270 {
1271 // Debug: If the clause asserts another clause into this same predicate, the iterator
1272 // over clauses will be corrupted. Should we take the time to copy clauses?
1273 foreach (IClause clause in clauses)
1274 {
1275 foreach (bool lastCall in clause.match(arguments))
1276 {
1277 yield return false;
1278 if (lastCall)
1279 // This happens after a cut in a clause.
1280 yield break;
1281 }
1282 }
1283 }
1284
1285 /// <summary>
1286 /// This is deprecated and just calls matchDynamic. This matches all clauses,
1287 /// not just the ones defined with assertFact.
1288 /// </summary>
1289 /// <param name="name"></param>
1290 /// <param name="arguments"></param>
1291 /// <returns></returns>
1292 public static IEnumerable<bool> matchFact(Atom name, object[] arguments)
1293 {
1294 return matchDynamic(name, arguments);
1295 }
1296
1297 /// <summary>
1298 /// This actually searches all clauses, not just
1299 /// the ones defined with assertFact, but we keep the name for
1300 /// backwards compatibility.
1301 /// </summary>
1302 /// <param name="name">must be an Atom</param>
1303 /// <param name="arguments">an array of arity number of arguments</param>
1304 public static void retractFact(Atom name, object[] arguments)
1305 {
1306 NameArity nameArity = new NameArity(name, arguments.Length);
1307 List<IClause> clauses;
1308 if (!_predicatesStore.TryGetValue(nameArity, out clauses))
1309 // Can't find, so ignore.
1310 return;
1311
1312 foreach (object arg in arguments)
1313 {
1314 if (!YP.var(arg))
1315 throw new InvalidOperationException("All arguments must be unbound");
1316 }
1317 // Set to a fresh empty IndexedAnswers.
1318 _predicatesStore[nameArity] = (clauses = new List<IClause>());
1319 clauses.Add(new IndexedAnswers());
1320 }
1321
1322 public static IEnumerable<bool> current_predicate(object NameSlashArity)
1323 {
1324 NameSlashArity = YP.getValue(NameSlashArity);
1325 // First check if Name and Arity are nonvar so we can do a direct lookup.
1326 if (YP.ground(NameSlashArity))
1327 {
1328 if (NameSlashArity is Functor2)
1329 {
1330 Functor2 NameArityFunctor = (Functor2)NameSlashArity;
1331 if (NameArityFunctor._name == Atom.SLASH)
1332 {
1333 if (_predicatesStore.ContainsKey(new NameArity
1334 ((Atom)YP.getValue(NameArityFunctor._arg1),
1335 (int)YP.getValue(NameArityFunctor._arg2))))
1336 // The predicate is defined.
1337 yield return false;
1338 }
1339 }
1340 yield break;
1341 }
1342
1343 foreach (NameArity key in _predicatesStore.Keys)
1344 {
1345 foreach (bool l1 in YP.unify
1346 (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity))
1347 yield return false;
1348 }
1349 }
1350
1351 /// <summary>
1352 /// Use YP.getFunctorName(Goal) and invoke the static method of this name in the
1353 /// declaringClass, using arguments from YP.getFunctorArgs(Goal).
1354 /// Note that Goal must be a simple functor, not a complex expression.
1355 /// If not found, this throws UndefinedPredicateException.
1356 /// </summary>
1357 /// <param name="Goal"></param>
1358 /// <param name="contextClass">the class for looking up default function references</param>
1359 /// <returns></returns>
1360 public static IEnumerable<bool> getIterator(object Goal, Type declaringClass)
1361 {
1362 Goal = YP.getValue(Goal);
1363 if (Goal is Variable)
1364 throw new PrologException("instantiation_error", "Goal to call is an unbound variable");
1365#if true
1366 List<Variable> variableSetList = new List<Variable>();
1367 addUniqueVariables(Goal, variableSetList);
1368 Variable[] variableSet = variableSetList.ToArray();
1369
1370 // Use Atom.F since it is ignored.
1371 return YPCompiler.compileAnonymousClause
1372 (Functor.make(Atom.F, variableSet), Goal, declaringClass).match(variableSet);
1373#else
1374 Atom name;
1375 object[] args;
1376 while (true)
1377 {
1378 name = (Atom)YP.getFunctorName(Goal);
1379 args = YP.getFunctorArgs(Goal);
1380 if (name == Atom.HAT && args.Length == 2)
1381 // Assume this is called from a bagof operation. Skip the leading qualifiers.
1382 Goal = YP.getValue(((Functor2)Goal)._arg2);
1383 else
1384 break;
1385 }
1386 try
1387 {
1388 return (IEnumerable<bool>)declaringClass.InvokeMember
1389 (name._name, BindingFlags.InvokeMethod, null, null, args);
1390 }
1391 catch (TargetInvocationException exception)
1392 {
1393 throw exception.InnerException;
1394 }
1395 catch (MissingMethodException)
1396 {
1397 throw new UndefinedPredicateException
1398 ("Cannot find predicate function: " + name + "/" + args.Length + " in " +
1399 declaringClass.FullName, name, args.Length);
1400 }
1401#endif
1402 }
1403
1404 public static void throwException(object Term)
1405 {
1406 throw new PrologException(Term);
1407 }
1408
1409 /// <summary>
1410 /// script_event calls hosting script with events as a callback method.
1411 /// </summary>
1412 /// <param name="script_event"></param>
1413 /// <param name="script_params"></param>
1414 /// <returns></returns>
1415 public static void script_event(object script_event, object script_params)
1416 {
1417 string function = ((Atom)YP.getValue(script_event))._name;
1418 object[] array = ListPair.toArray(script_params);
1419 if (array == null)
1420 return; // YP.fail();
1421 if (array.Length > 1)
1422 {
1423 //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue
1424 //(localID, itemID, function, array);
1425 // sortArray(array);
1426 }
1427 //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array));
1428 }
1429
1430 /// <summary>
1431 /// An enumerator that does zero loops.
1432 /// </summary>
1433 private class Fail : IEnumerator<bool>, IEnumerable<bool>
1434 {
1435 public bool MoveNext()
1436 {
1437 return false;
1438 }
1439
1440 public IEnumerator<bool> GetEnumerator()
1441 {
1442 return (IEnumerator<bool>)this;
1443 }
1444
1445 IEnumerator IEnumerable.GetEnumerator()
1446 {
1447 return GetEnumerator();
1448 }
1449
1450 public bool Current
1451 {
1452 get { return true; }
1453 }
1454
1455 object IEnumerator.Current
1456 {
1457 get { return true; }
1458 }
1459
1460 public void Dispose()
1461 {
1462 }
1463
1464 public void Reset()
1465 {
1466 throw new NotImplementedException();
1467 }
1468 }
1469
1470 /// <summary>
1471 /// An enumerator that does one iteration.
1472 /// </summary>
1473 private class Succeed : IEnumerator<bool>, IEnumerable<bool>
1474 {
1475 private bool _didIteration = false;
1476
1477 public bool MoveNext()
1478 {
1479 if (!_didIteration)
1480 {
1481 _didIteration = true;
1482 return true;
1483 }
1484 else
1485 return false;
1486 }
1487
1488 public IEnumerator<bool> GetEnumerator()
1489 {
1490 return (IEnumerator<bool>)this;
1491 }
1492
1493 IEnumerator IEnumerable.GetEnumerator()
1494 {
1495 return GetEnumerator();
1496 }
1497
1498 public bool Current
1499 {
1500 get { return false; }
1501 }
1502
1503 object IEnumerator.Current
1504 {
1505 get { return false; }
1506 }
1507
1508 public void Dispose()
1509 {
1510 }
1511
1512 public void Reset()
1513 {
1514 throw new NotImplementedException();
1515 }
1516 }
1517
1518 /// <summary>
1519 /// An enumerator that repeats forever.
1520 /// </summary>
1521 private class Repeat : IEnumerator<bool>, IEnumerable<bool>
1522 {
1523 public bool MoveNext()
1524 {
1525 return true;
1526 }
1527
1528 public IEnumerator<bool> GetEnumerator()
1529 {
1530 return (IEnumerator<bool>)this;
1531 }
1532
1533 IEnumerator IEnumerable.GetEnumerator()
1534 {
1535 return GetEnumerator();
1536 }
1537
1538 public bool Current
1539 {
1540 get { return false; }
1541 }
1542
1543 object IEnumerator.Current
1544 {
1545 get { return false; }
1546 }
1547
1548 public void Dispose()
1549 {
1550 }
1551
1552 public void Reset()
1553 {
1554 throw new NotImplementedException();
1555 }
1556 }
1557
1558 /// <summary>
1559 /// An enumerator that wraps another enumerator in order to catch a PrologException.
1560 /// </summary>
1561 public class Catch : IEnumerator<bool>, IEnumerable<bool>
1562 {
1563 private IEnumerator<bool> _enumerator;
1564 private PrologException _exception = null;
1565
1566 public Catch(IEnumerable<bool> iterator)
1567 {
1568 _enumerator = iterator.GetEnumerator();
1569 }
1570
1571 /// <summary>
1572 /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception
1573 /// and return false. After this returns false, call unifyExceptionOrThrow.
1574 /// Assume that, after this returns false, it will not be called again.
1575 /// </summary>
1576 /// <returns></returns>
1577 public bool MoveNext()
1578 {
1579 try
1580 {
1581 return _enumerator.MoveNext();
1582 }
1583 catch (PrologException exception)
1584 {
1585 _exception = exception;
1586 return false;
1587 }
1588 }
1589
1590 /// <summary>
1591 /// Call this after MoveNext() returns false to check for an exception. If
1592 /// MoveNext did not get a PrologException, don't yield.
1593 /// Otherwise, unify the exception with Catcher and yield so the caller can
1594 /// do the handler code. However, if can't unify with Catcher then throw the exception.
1595 /// </summary>
1596 /// <param name="Catcher"></param>
1597 /// <returns></returns>
1598 public IEnumerable<bool> unifyExceptionOrThrow(object Catcher)
1599 {
1600 if (_exception != null)
1601 {
1602 bool didUnify = false;
1603 foreach (bool l1 in YP.unify(_exception._term, Catcher))
1604 {
1605 didUnify = true;
1606 yield return false;
1607 }
1608 if (!didUnify)
1609 throw _exception;
1610 }
1611 }
1612
1613 public IEnumerator<bool> GetEnumerator()
1614 {
1615 return (IEnumerator<bool>)this;
1616 }
1617
1618 IEnumerator IEnumerable.GetEnumerator()
1619 {
1620 return GetEnumerator();
1621 }
1622
1623 public bool Current
1624 {
1625 get { return _enumerator.Current; }
1626 }
1627
1628 object IEnumerator.Current
1629 {
1630 get { return _enumerator.Current; }
1631 }
1632
1633 public void Dispose()
1634 {
1635 _enumerator.Dispose();
1636 }
1637
1638 public void Reset()
1639 {
1640 throw new NotImplementedException();
1641 }
1642 }
1643 }
1644}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
new file mode 100644
index 0000000..f2f8145
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
@@ -0,0 +1,5651 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.IO;
33using System.Collections;
34using System.Collections.Generic;
35using System.Text;
36using System.CodeDom.Compiler;
37
38namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
39{
40 public class YPCompiler
41 {
42 private class CompilerState
43 {
44 public IndexedAnswers _pred = new IndexedAnswers();
45 public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>();
46 public int _gensymCounter;
47 public bool _useFinalCutCode;
48 public Variable _finalCutCode;
49 public bool _codeUsesYield;
50 public Atom _determinism;
51 // a list of '='(Name, Variable)
52 public List<object> _variableNames;
53
54 // Make these static functions that explicitly take the State so Prolog can call it.
55
56 /// <summary>
57 /// Make a new CompilerState and bind it to State.
58 /// </summary>
59 /// <param name="State"></param>
60 /// <returns></returns>
61 public static IEnumerable<bool> make(object State)
62 {
63 return YP.unify(State, new CompilerState());
64 }
65
66 public static void assertPred(object State, object Pred, object Determinism)
67 {
68 State = YP.getValue(State);
69 object functorName = YP.getFunctorName(Pred);
70 object[] functorArgs = YP.getFunctorArgs(Pred);
71 // Debug: Should check if it's already asserted and is the same.
72 ((CompilerState)State)._pred.addAnswer
73 (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) });
74 }
75
76 public static void assertModuleForNameArity(object State, object Name, object Arity, object Module)
77 {
78 State = YP.getValue(State);
79 Name = YP.getValue(Name);
80 Arity = YP.getValue(Arity);
81 Module = YP.getValue(Module);
82 // If the Module Atom comes from the parser, it always has null _declaringClass.
83 if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int)
84 {
85 // Replace a previous entry if it exists.
86 ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] =
87 (Atom)Module;
88 }
89 }
90
91 public static void startFunction(object State, object Head)
92 {
93 State = YP.getValue(State);
94 ((CompilerState)State)._gensymCounter = 0;
95 ((CompilerState)State)._useFinalCutCode = false;
96 ((CompilerState)State)._finalCutCode = new Variable();
97 ((CompilerState)State)._codeUsesYield = false;
98 if (CompilerState.isDetNoneOut(State, Head))
99 ((CompilerState)State)._determinism = Atom.a("detNoneOut");
100 else if (CompilerState.isSemidetNoneOut(State, Head))
101 ((CompilerState)State)._determinism = Atom.a("semidetNoneOut");
102 else
103 ((CompilerState)State)._determinism = Atom.a("nondet");
104 }
105
106 public static void setCodeUsesYield(object State)
107 {
108 State = YP.getValue(State);
109 ((CompilerState)State)._codeUsesYield = true;
110 }
111
112 public static bool codeUsesYield(object State)
113 {
114 State = YP.getValue(State);
115 return ((CompilerState)State)._codeUsesYield;
116 }
117
118 public static bool determinismEquals(object State, object Term)
119 {
120 State = YP.getValue(State);
121 return YP.termEqual(((CompilerState)State)._determinism, Term);
122 }
123
124 /// <summary>
125 /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule.
126 /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc.
127 /// </summary>
128 /// <param name="State"></param>
129 /// <param name="rule"></param>
130 /// <param name="variableNameSuggestions"></param>
131 public static void newVariableNames(object State, object Rule, object VariableNameSuggestions)
132 {
133 State = YP.getValue(State);
134 List<Variable> variablesSet = new List<Variable>();
135 YP.addUniqueVariables(Rule, variablesSet);
136
137 ((CompilerState)State)._variableNames = new List<object>();
138 int xCounter = 0;
139 foreach (Variable variable in variablesSet)
140 ((CompilerState)State)._variableNames.Add
141 (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter),
142 variable));
143 }
144
145 private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter)
146 {
147 // Debug: should require named variables to start with _ or capital. Should
148 // check for duplicates and clashes with keywords.
149 for (object element = YP.getValue(variableNameSuggestions);
150 element is Functor2 && ((Functor2)element)._name == Atom.DOT;
151 element = YP.getValue(((Functor2)element)._arg2))
152 {
153 object suggestionPair = YP.getValue(((Functor2)element)._arg1);
154 if (sameVariable(variable, ((Functor2)suggestionPair)._arg2))
155 {
156 Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1);
157 if (suggestion.Equals(Atom.a("Atom")))
158 suggestion = Atom.a("Atom_1");
159 if (suggestion.Equals(Atom.a("Variable")))
160 suggestion = Atom.a("Variable_1");
161 if (suggestion.Equals(Atom.a("Functor")))
162 suggestion = Atom.a("Functor_1");
163 return suggestion;
164 }
165 }
166
167 return Atom.a("x" + xCounter);
168 }
169
170 /// <summary>
171 /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames
172 /// for variable.
173 /// </summary>
174 /// <param name="variable">a Variable</param>
175 /// <param name="State"></param>
176 /// <param name="Result">the assigned Name</param>
177 public static IEnumerable<bool> getVariableName(object State, object variable, object Result)
178 {
179 State = YP.getValue(State);
180 foreach (object variableInfo in ((CompilerState)State)._variableNames)
181 {
182 if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("=")))
183 {
184 if (sameVariable(variable, ((Functor2)variableInfo)._arg2))
185 return YP.unify(Result, ((Functor2)variableInfo)._arg1);
186 }
187 }
188
189 // We set up names for all unique variables, so this should never happen.
190 throw new PrologException(Atom.a("Can't find entry in _variableNames"));
191 }
192
193 public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList)
194 {
195 State = YP.getValue(State);
196 return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames));
197 }
198
199 public static IEnumerable<bool> gensym(object State, object Base, object Symbol)
200 {
201 State = YP.getValue(State);
202 return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter));
203 }
204
205 public static bool isDetNoneOut(object State, object Term)
206 {
207 State = YP.getValue(State);
208 object functorName = YP.getFunctorName(Term);
209 object[] functorArgs = YP.getFunctorArgs(Term);
210
211 Variable pred = new Variable();
212 foreach (bool l1 in ((CompilerState)State)._pred.match
213 (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") }))
214 {
215 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
216 {
217 return true;
218 }
219 }
220
221 return false;
222 }
223
224 public static bool isSemidetNoneOut(object State, object Term)
225 {
226 State = YP.getValue(State);
227 object functorName = YP.getFunctorName(Term);
228 object[] functorArgs = YP.getFunctorArgs(Term);
229
230 Variable pred = new Variable();
231 foreach (bool l1 in ((CompilerState)State)._pred.match
232 (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") }))
233 {
234 if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
235 {
236 return true;
237 }
238 }
239
240 return false;
241 }
242
243 /// <summary>
244 /// Return false if any of args is out, otherwise true.
245 /// args is an array of ::(Type,Mode) where Mode is in or out.
246 /// </summary>
247 /// <param name="args"></param>
248 /// <returns></returns>
249 private static bool isNoneOut(object[] args)
250 {
251 foreach (object arg in args)
252 {
253 if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") &&
254 ((Functor2)arg)._arg2 == Atom.a("out"))
255 return false;
256 }
257 return true;
258 }
259
260 public static bool nameArityHasModule(object State, object Name, object Arity, object Module)
261 {
262 State = YP.getValue(State);
263 Name = YP.getValue(Name);
264 Arity = YP.getValue(Arity);
265 Module = YP.getValue(Module);
266 if (Name is Atom && Arity is int)
267 {
268 Atom FoundModule;
269 if (!((CompilerState)State)._moduleForNameArity.TryGetValue
270 (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule))
271 return false;
272 return FoundModule == Module;
273 }
274 return false;
275 }
276 }
277
278 /// <summary>
279 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
280 /// to return an anonymous YP.IClause for the Head and Body of a rule clause.
281 /// </summary>
282 /// <param name="Head">a prolog term such as new Functor2("test1", X, Y).
283 /// Note that the name of the head is ignored.
284 /// </param>
285 /// <param name="Body">a prolog term such as
286 /// new Functor2(",", new Functor1(Atom.a("test2", Atom.a("")), X),
287 /// new Functor2("=", Y, X)).
288 /// This may not be null. (For a head-only clause, set the Body to Atom.a("true").
289 /// </param>
290 /// <param name="declaringClass">if not null, the code is compiled as a subclass of this class
291 /// to resolve references to the default module Atom.a("")</param>
292 /// <returns>a new YP.IClause object on which you can call match(object[] args) where
293 /// args length is the arity of the Head</returns>
294 public static YP.IClause compileAnonymousClause(object Head, object Body, Type declaringClass)
295 {
296 object[] args = YP.getFunctorArgs(Head);
297 // compileAnonymousFunction wants "function".
298 object Rule = new Functor2(Atom.RULE, Functor.make("function", args), Body);
299 object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL));
300
301 StringWriter functionCode = new StringWriter();
302 Variable SaveOutputStream = new Variable();
303 foreach (bool l1 in YP.current_output(SaveOutputStream))
304 {
305 try
306 {
307 YP.tell(functionCode);
308 Variable FunctionCode = new Variable();
309 foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode))
310 {
311 if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass")))
312 // Ignore getDeclaringClass since we have access to the one passed in.
313 continue;
314
315 // Debug: should check if FunctionCode is a single call.
316 convertFunctionCSharp(FunctionCode);
317 }
318 YP.told();
319 }
320 finally
321 {
322 // Restore after calling tell.
323 YP.tell(SaveOutputStream.getValue());
324 }
325 }
326 return YPCompiler.compileAnonymousFunction
327 (functionCode.ToString(), args.Length, declaringClass);
328 }
329
330 /// <summary>
331 /// Use CodeDomProvider to compile the functionCode and return a YP.IClause.
332 /// The function name must be "function" and have nArgs arguments.
333 /// </summary>
334 /// <param name="functionCode">the code for the iterator, such as
335 /// "public static IEnumerable<bool> function() { yield return false; }"
336 /// </param>
337 /// <param name="nArgs">the number of args in the function</param>
338 /// <param name="declaringClass">if not null, then use the functionCode inside a class which
339 /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't
340 /// have to be qualified</param>
341 /// <returns>a new YP.IClause object on which you can call match(object[] args) where
342 /// args length is nArgs</returns>
343 public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass)
344 {
345 CompilerParameters parameters = new CompilerParameters();
346 // This gets the location of the System assembly.
347 parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location);
348 // This gets the location of this assembly which also has YieldProlog.YP, etc.
349 parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location);
350 if (declaringClass != null)
351 parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location);
352 parameters.GenerateInMemory = true;
353
354 StringBuilder sourceCode = new StringBuilder();
355 sourceCode.Append(@"
356using System;
357using System.Collections.Generic;
358using YieldProlog;
359
360namespace Temporary {
361 public class Temporary : YP.IClause {
362 public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" {
363");
364 sourceCode.Append(functionCode);
365 // Basically, match applies the args to function.
366 sourceCode.Append(@"
367 }
368 public IEnumerable<bool> match(object[] args) {
369 return Inner.function(");
370 if (nArgs >= 1)
371 sourceCode.Append("args[0]");
372 for (int i = 1; i < nArgs; ++i)
373 sourceCode.Append(", args[" + i + "]");
374 sourceCode.Append(@");
375 }
376 }
377}
378");
379
380 CompilerResults results = CodeDomProvider.CreateProvider
381 ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString());
382 if (results.Errors.Count > 0)
383 throw new Exception("Error evaluating code: " + results.Errors[0]);
384
385 // Return a new Temporary.Temporary object.
386 return (YP.IClause)results.CompiledAssembly.GetType
387 ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
388 }
389
390 // Compiler output follows.
391
392 public class YPInnerClass { }
393 public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
394
395 public static void repeatWrite(object arg1, object N)
396 {
397 {
398 object _Value = arg1;
399 if (YP.termEqual(N, 0))
400 {
401 return;
402 }
403 }
404 {
405 object Value = arg1;
406 Variable NextN = new Variable();
407 YP.write(Value);
408 foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1)))
409 {
410 repeatWrite(Value, NextN);
411 return;
412 }
413 }
414 }
415
416 public static bool sameVariable(object Variable1, object Variable2)
417 {
418 {
419 if (YP.var(Variable1))
420 {
421 if (YP.var(Variable2))
422 {
423 if (YP.termEqual(Variable1, Variable2))
424 {
425 return true;
426 }
427 }
428 }
429 }
430 return false;
431 }
432
433 public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
434 {
435 {
436 Variable State = new Variable();
437 foreach (bool l2 in CompilerState.make(State))
438 {
439 CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det"));
440 CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
441 CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
442 CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
443 CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
444 CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
445 CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
446 CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
447 CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
448 CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
449 CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
450 CompilerState.assertPred(State, new Functor1(@"compound", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
451 CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
452 CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
453 CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
454 CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
455 CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
456 CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
457 processCompilerDirectives(RuleList, State);
458 foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass")))
459 {
460 yield return false;
461 }
462 foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
463 {
464 yield return false;
465 }
466 }
467 }
468 }
469
470 public static void processCompilerDirectives(object arg1, object arg2)
471 {
472 {
473 object _State = arg2;
474 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
475 {
476 return;
477 }
478 }
479 {
480 object State = arg2;
481 Variable Pred = new Variable();
482 Variable Determinism = new Variable();
483 Variable x3 = new Variable();
484 Variable RestRules = new Variable();
485 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules)))
486 {
487 CompilerState.assertPred(State, Pred, Determinism);
488 processCompilerDirectives(RestRules, State);
489 return;
490 }
491 }
492 {
493 object State = arg2;
494 Variable Module = new Variable();
495 Variable PredicateList = new Variable();
496 Variable x3 = new Variable();
497 Variable RestRules = new Variable();
498 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules)))
499 {
500 foreach (bool l3 in importPredicateList(State, Module, PredicateList))
501 {
502 processCompilerDirectives(RestRules, State);
503 return;
504 }
505 }
506 }
507 {
508 object State = arg2;
509 Variable x1 = new Variable();
510 Variable x2 = new Variable();
511 Variable RestRules = new Variable();
512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules)))
513 {
514 processCompilerDirectives(RestRules, State);
515 return;
516 }
517 }
518 {
519 object State = arg2;
520 Variable Head = new Variable();
521 Variable _Body = new Variable();
522 Variable x3 = new Variable();
523 Variable RestRules = new Variable();
524 Variable Name = new Variable();
525 Variable Arity = new Variable();
526 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules)))
527 {
528 foreach (bool l3 in YP.functor(Head, Name, Arity))
529 {
530 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
531 processCompilerDirectives(RestRules, State);
532 return;
533 }
534 }
535 }
536 {
537 object State = arg2;
538 Variable Fact = new Variable();
539 Variable x2 = new Variable();
540 Variable RestRules = new Variable();
541 Variable Name = new Variable();
542 Variable Arity = new Variable();
543 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules)))
544 {
545 foreach (bool l3 in YP.functor(Fact, Name, Arity))
546 {
547 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
548 processCompilerDirectives(RestRules, State);
549 return;
550 }
551 }
552 }
553 {
554 object State = arg2;
555 Variable x1 = new Variable();
556 Variable RestRules = new Variable();
557 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules)))
558 {
559 processCompilerDirectives(RestRules, State);
560 return;
561 }
562 }
563 }
564
565 public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
566 {
567 {
568 object _State = arg1;
569 object _Module = arg2;
570 foreach (bool l2 in YP.unify(arg3, Atom.NIL))
571 {
572 yield return true;
573 yield break;
574 }
575 }
576 {
577 object State = arg1;
578 object Module = arg2;
579 Variable Name = new Variable();
580 Variable Arity = new Variable();
581 Variable Rest = new Variable();
582 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest)))
583 {
584 CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
585 foreach (bool l3 in importPredicateList(State, Module, Rest))
586 {
587 yield return true;
588 yield break;
589 }
590 }
591 }
592 {
593 object State = arg1;
594 object Module = arg2;
595 Variable x3 = new Variable();
596 Variable Rest = new Variable();
597 foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
598 {
599 foreach (bool l3 in importPredicateList(State, Module, Rest))
600 {
601 yield return true;
602 yield break;
603 }
604 }
605 }
606 }
607
608 public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode)
609 {
610 {
611 Variable SamePredicateRuleList = new Variable();
612 Variable RestRules = new Variable();
613 foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules))
614 {
615 if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL))
616 {
617 foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode))
618 {
619 yield return false;
620 }
621 foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode))
622 {
623 yield return false;
624 }
625 }
626 }
627 }
628 }
629
630 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
631 {
632 {
633 Variable FirstRule = new Variable();
634 Variable x5 = new Variable();
635 Variable x6 = new Variable();
636 Variable x7 = new Variable();
637 Variable Head = new Variable();
638 Variable x9 = new Variable();
639 Variable ArgAssignments = new Variable();
640 Variable Calls = new Variable();
641 Variable Rule = new Variable();
642 Variable VariableNameSuggestions = new Variable();
643 Variable ClauseBag = new Variable();
644 Variable Name = new Variable();
645 Variable ArgsList = new Variable();
646 Variable FunctionArgNames = new Variable();
647 Variable MergedArgName = new Variable();
648 Variable ArgName = new Variable();
649 Variable MergedArgNames = new Variable();
650 Variable FunctionArgs = new Variable();
651 Variable BodyCode = new Variable();
652 Variable ReturnType = new Variable();
653 Variable BodyWithReturn = new Variable();
654 foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList))
655 {
656 foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7)))
657 {
658 goto cutIf1;
659 }
660 foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule))
661 {
662 CompilerState.startFunction(State, Head);
663 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
664 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
665 {
666 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
667 {
668 findallAnswers3.add();
669 }
670 }
671 foreach (bool l4 in findallAnswers3.result(ClauseBag))
672 {
673 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
674 {
675 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
676 {
677 FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
678 foreach (bool l7 in member(ArgName, FunctionArgNames))
679 {
680 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
681 {
682 findallAnswers4.add();
683 goto cutIf5;
684 }
685 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
686 {
687 findallAnswers4.add();
688 }
689 cutIf5:
690 { }
691 }
692 foreach (bool l7 in findallAnswers4.result(MergedArgNames))
693 {
694 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
695 {
696 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
697 {
698 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
699 {
700 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
701 {
702 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
703 {
704 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
705 {
706 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
707 {
708 yield return false;
709 }
710 }
711 goto cutIf7;
712 }
713 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
714 {
715 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
716 {
717 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
718 {
719 yield return false;
720 }
721 }
722 goto cutIf8;
723 }
724 if (CompilerState.codeUsesYield(State))
725 {
726 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
727 {
728 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
729 {
730 yield return false;
731 }
732 }
733 goto cutIf9;
734 }
735 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
736 {
737 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
738 {
739 yield return false;
740 }
741 }
742 cutIf9:
743 cutIf8:
744 cutIf7:
745 { }
746 }
747 goto cutIf6;
748 }
749 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
750 {
751 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
752 {
753 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
754 {
755 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
756 {
757 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
758 {
759 yield return false;
760 }
761 }
762 goto cutIf11;
763 }
764 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
765 {
766 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
767 {
768 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
769 {
770 yield return false;
771 }
772 }
773 goto cutIf12;
774 }
775 if (CompilerState.codeUsesYield(State))
776 {
777 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
778 {
779 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
780 {
781 yield return false;
782 }
783 }
784 goto cutIf13;
785 }
786 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
787 {
788 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
789 {
790 yield return false;
791 }
792 }
793 cutIf13:
794 cutIf12:
795 cutIf11:
796 { }
797 }
798 goto cutIf10;
799 }
800 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
801 {
802 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
803 {
804 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
805 {
806 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
807 {
808 yield return false;
809 }
810 }
811 goto cutIf14;
812 }
813 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
814 {
815 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
816 {
817 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
818 {
819 yield return false;
820 }
821 }
822 goto cutIf15;
823 }
824 if (CompilerState.codeUsesYield(State))
825 {
826 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
827 {
828 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
829 {
830 yield return false;
831 }
832 }
833 goto cutIf16;
834 }
835 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
836 {
837 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
838 {
839 yield return false;
840 }
841 }
842 cutIf16:
843 cutIf15:
844 cutIf14:
845 { }
846 }
847 cutIf10:
848 cutIf6:
849 { }
850 }
851 }
852 }
853 }
854 }
855 }
856 goto cutIf2;
857 }
858 foreach (bool l3 in YP.unify(Head, FirstRule))
859 {
860 CompilerState.startFunction(State, Head);
861 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
862 foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
863 {
864 foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
865 {
866 findallAnswers17.add();
867 }
868 }
869 foreach (bool l4 in findallAnswers17.result(ClauseBag))
870 {
871 foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
872 {
873 foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
874 {
875 FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
876 foreach (bool l7 in member(ArgName, FunctionArgNames))
877 {
878 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
879 {
880 findallAnswers18.add();
881 goto cutIf19;
882 }
883 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
884 {
885 findallAnswers18.add();
886 }
887 cutIf19:
888 { }
889 }
890 foreach (bool l7 in findallAnswers18.result(MergedArgNames))
891 {
892 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
893 {
894 foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
895 {
896 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
897 {
898 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
899 {
900 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
901 {
902 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
903 {
904 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
905 {
906 yield return false;
907 }
908 }
909 goto cutIf21;
910 }
911 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
912 {
913 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
914 {
915 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
916 {
917 yield return false;
918 }
919 }
920 goto cutIf22;
921 }
922 if (CompilerState.codeUsesYield(State))
923 {
924 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
925 {
926 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
927 {
928 yield return false;
929 }
930 }
931 goto cutIf23;
932 }
933 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
934 {
935 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
936 {
937 yield return false;
938 }
939 }
940 cutIf23:
941 cutIf22:
942 cutIf21:
943 { }
944 }
945 goto cutIf20;
946 }
947 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
948 {
949 foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
950 {
951 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
952 {
953 foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
954 {
955 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
956 {
957 yield return false;
958 }
959 }
960 goto cutIf25;
961 }
962 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
963 {
964 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
965 {
966 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
967 {
968 yield return false;
969 }
970 }
971 goto cutIf26;
972 }
973 if (CompilerState.codeUsesYield(State))
974 {
975 foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
976 {
977 foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
978 {
979 yield return false;
980 }
981 }
982 goto cutIf27;
983 }
984 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
985 {
986 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
987 {
988 yield return false;
989 }
990 }
991 cutIf27:
992 cutIf26:
993 cutIf25:
994 { }
995 }
996 goto cutIf24;
997 }
998 foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
999 {
1000 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1001 {
1002 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
1003 {
1004 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1005 {
1006 yield return false;
1007 }
1008 }
1009 goto cutIf28;
1010 }
1011 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1012 {
1013 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1014 {
1015 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1016 {
1017 yield return false;
1018 }
1019 }
1020 goto cutIf29;
1021 }
1022 if (CompilerState.codeUsesYield(State))
1023 {
1024 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
1025 {
1026 foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1027 {
1028 yield return false;
1029 }
1030 }
1031 goto cutIf30;
1032 }
1033 foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
1034 {
1035 foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
1036 {
1037 yield return false;
1038 }
1039 }
1040 cutIf30:
1041 cutIf29:
1042 cutIf28:
1043 { }
1044 }
1045 cutIf24:
1046 cutIf20:
1047 { }
1048 }
1049 }
1050 }
1051 }
1052 }
1053 }
1054 }
1055 cutIf2:
1056 cutIf1:
1057 { }
1058 }
1059 }
1060 }
1061
1062 public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3)
1063 {
1064 {
1065 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1066 {
1067 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1068 {
1069 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1070 {
1071 yield return true;
1072 yield break;
1073 }
1074 }
1075 }
1076 }
1077 {
1078 Variable First = new Variable();
1079 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL)))
1080 {
1081 foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL)))
1082 {
1083 foreach (bool l4 in YP.unify(arg3, Atom.NIL))
1084 {
1085 yield return true;
1086 yield break;
1087 }
1088 }
1089 }
1090 }
1091 {
1092 object SamePredicateRuleList = arg2;
1093 object RestRules = arg3;
1094 Variable First = new Variable();
1095 Variable Rest = new Variable();
1096 Variable FirstRule = new Variable();
1097 Variable x6 = new Variable();
1098 Variable SecondRule = new Variable();
1099 Variable x8 = new Variable();
1100 Variable x9 = new Variable();
1101 Variable FirstHead = new Variable();
1102 Variable x11 = new Variable();
1103 Variable SecondHead = new Variable();
1104 Variable x13 = new Variable();
1105 Variable Name = new Variable();
1106 Variable Arity = new Variable();
1107 Variable RestSamePredicates = new Variable();
1108 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1109 {
1110 foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First))
1111 {
1112 foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest))
1113 {
1114 foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule))
1115 {
1116 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1117 {
1118 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1119 {
1120 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1121 {
1122 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1123 {
1124 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1125 {
1126 yield return true;
1127 yield break;
1128 }
1129 }
1130 goto cutIf3;
1131 }
1132 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1133 {
1134 foreach (bool l9 in YP.unify(RestRules, Rest))
1135 {
1136 yield return true;
1137 yield break;
1138 }
1139 }
1140 cutIf3:
1141 { }
1142 }
1143 goto cutIf2;
1144 }
1145 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1146 {
1147 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1148 {
1149 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1150 {
1151 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1152 {
1153 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1154 {
1155 yield return true;
1156 yield break;
1157 }
1158 }
1159 goto cutIf4;
1160 }
1161 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1162 {
1163 foreach (bool l9 in YP.unify(RestRules, Rest))
1164 {
1165 yield return true;
1166 yield break;
1167 }
1168 }
1169 cutIf4:
1170 { }
1171 }
1172 }
1173 cutIf2:
1174 goto cutIf1;
1175 }
1176 foreach (bool l5 in YP.unify(FirstHead, FirstRule))
1177 {
1178 foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
1179 {
1180 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1181 {
1182 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1183 {
1184 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1185 {
1186 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1187 {
1188 yield return true;
1189 yield break;
1190 }
1191 }
1192 goto cutIf6;
1193 }
1194 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1195 {
1196 foreach (bool l9 in YP.unify(RestRules, Rest))
1197 {
1198 yield return true;
1199 yield break;
1200 }
1201 }
1202 cutIf6:
1203 { }
1204 }
1205 goto cutIf5;
1206 }
1207 foreach (bool l6 in YP.unify(SecondHead, SecondRule))
1208 {
1209 foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
1210 {
1211 foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
1212 {
1213 foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
1214 {
1215 foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
1216 {
1217 yield return true;
1218 yield break;
1219 }
1220 }
1221 goto cutIf7;
1222 }
1223 foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
1224 {
1225 foreach (bool l9 in YP.unify(RestRules, Rest))
1226 {
1227 yield return true;
1228 yield break;
1229 }
1230 }
1231 cutIf7:
1232 { }
1233 }
1234 }
1235 cutIf5:
1236 { }
1237 }
1238 cutIf1:
1239 { }
1240 }
1241 }
1242 }
1243 }
1244 }
1245
1246 public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3)
1247 {
1248 {
1249 object _MergedArgNames = arg2;
1250 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1251 {
1252 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1253 {
1254 yield return true;
1255 yield break;
1256 }
1257 }
1258 }
1259 {
1260 object MergedArgNames = arg2;
1261 Variable ArgAssignments = new Variable();
1262 Variable Calls = new Variable();
1263 Variable Rest = new Variable();
1264 Variable ClauseCode = new Variable();
1265 Variable RestResults = new Variable();
1266 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest)))
1267 {
1268 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults)))
1269 {
1270 foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
1271 {
1272 foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults))
1273 {
1274 yield return true;
1275 yield break;
1276 }
1277 }
1278 }
1279 }
1280 }
1281 }
1282
1283 public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4)
1284 {
1285 {
1286 object _MergedArgNames = arg3;
1287 Variable In = new Variable();
1288 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1289 {
1290 foreach (bool l3 in YP.unify(arg2, In))
1291 {
1292 foreach (bool l4 in YP.unify(arg4, In))
1293 {
1294 yield return true;
1295 yield break;
1296 }
1297 }
1298 }
1299 }
1300 {
1301 object In = arg2;
1302 object MergedArgNames = arg3;
1303 object ClauseCode = arg4;
1304 Variable VariableName = new Variable();
1305 Variable ArgName = new Variable();
1306 Variable RestArgAssignments = new Variable();
1307 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments)))
1308 {
1309 foreach (bool l3 in member(VariableName, MergedArgNames))
1310 {
1311 foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode))
1312 {
1313 yield return true;
1314 yield break;
1315 }
1316 goto cutIf1;
1317 }
1318 foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode))
1319 {
1320 yield return true;
1321 yield break;
1322 }
1323 cutIf1:
1324 { }
1325 }
1326 }
1327 }
1328
1329 public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName)
1330 {
1331 {
1332 object _ArgName = arg1;
1333 foreach (bool l2 in YP.unify(arg2, Atom.NIL))
1334 {
1335 if (YP.nonvar(VariableName))
1336 {
1337 yield return true;
1338 yield break;
1339 }
1340 }
1341 }
1342 {
1343 object ArgName = arg1;
1344 Variable ArgAssignments = new Variable();
1345 Variable _Calls = new Variable();
1346 Variable RestClauseBag = new Variable();
1347 foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag)))
1348 {
1349 foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments))
1350 {
1351 foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
1352 {
1353 yield return false;
1354 }
1355 }
1356 }
1357 }
1358 }
1359
1360 public static IEnumerable<bool> maplist_arg(object arg1, object arg2)
1361 {
1362 {
1363 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1364 {
1365 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1366 {
1367 yield return true;
1368 yield break;
1369 }
1370 }
1371 }
1372 {
1373 Variable First = new Variable();
1374 Variable Rest = new Variable();
1375 Variable RestResults = new Variable();
1376 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
1377 {
1378 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults)))
1379 {
1380 foreach (bool l4 in maplist_arg(Rest, RestResults))
1381 {
1382 yield return true;
1383 yield break;
1384 }
1385 }
1386 }
1387 }
1388 }
1389
1390 public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3)
1391 {
1392 {
1393 object _StartArgNumber = arg2;
1394 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1395 {
1396 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1397 {
1398 yield return true;
1399 yield break;
1400 }
1401 }
1402 }
1403 {
1404 object StartArgNumber = arg2;
1405 Variable x1 = new Variable();
1406 Variable Rest = new Variable();
1407 Variable ArgName = new Variable();
1408 Variable RestFunctionArgs = new Variable();
1409 Variable NumberCodes = new Variable();
1410 Variable NumberAtom = new Variable();
1411 Variable NextArgNumber = new Variable();
1412 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest)))
1413 {
1414 foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs)))
1415 {
1416 foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes))
1417 {
1418 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1419 {
1420 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1421 {
1422 foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
1423 {
1424 foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs))
1425 {
1426 yield return true;
1427 yield break;
1428 }
1429 }
1430 }
1431 }
1432 }
1433 }
1434 }
1435 }
1436 }
1437
1438 public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls)
1439 {
1440 {
1441 Variable Head = new Variable();
1442 Variable Body = new Variable();
1443 Variable x8 = new Variable();
1444 Variable HeadArgs = new Variable();
1445 Variable CompiledHeadArgs = new Variable();
1446 Variable BodyCode = new Variable();
1447 Variable VariableNamesList = new Variable();
1448 Variable ArgUnifications = new Variable();
1449 foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule))
1450 {
1451 CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
1452 foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
1453 {
1454 foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs))
1455 {
1456 foreach (bool l5 in compileRuleBody(Body, State, BodyCode))
1457 {
1458 foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList))
1459 {
1460 foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications))
1461 {
1462 foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls))
1463 {
1464 yield return true;
1465 yield break;
1466 }
1467 }
1468 }
1469 }
1470 }
1471 }
1472 }
1473 }
1474 {
1475 foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls))
1476 {
1477 yield return true;
1478 yield break;
1479 }
1480 }
1481 }
1482
1483 public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1484 {
1485 {
1486 object x1 = arg2;
1487 object x2 = arg3;
1488 object x3 = arg4;
1489 Variable BodyCode = new Variable();
1490 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1491 {
1492 foreach (bool l3 in YP.unify(arg5, BodyCode))
1493 {
1494 foreach (bool l4 in YP.unify(arg6, BodyCode))
1495 {
1496 yield return true;
1497 yield break;
1498 }
1499 }
1500 }
1501 }
1502 {
1503 object Index = arg3;
1504 object AllHeadArgs = arg4;
1505 object BodyCode = arg5;
1506 object ArgUnifications = arg6;
1507 Variable HeadArg = new Variable();
1508 Variable RestHeadArgs = new Variable();
1509 Variable x3 = new Variable();
1510 Variable RestCompiledHeadArgs = new Variable();
1511 Variable _ArgIndex1 = new Variable();
1512 Variable NextIndex = new Variable();
1513 foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs)))
1514 {
1515 foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs)))
1516 {
1517 foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1))
1518 {
1519 foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1)))
1520 {
1521 foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications))
1522 {
1523 yield return true;
1524 yield break;
1525 }
1526 }
1527 }
1528 }
1529 }
1530 }
1531 {
1532 object Index = arg3;
1533 object AllHeadArgs = arg4;
1534 object BodyCode = arg5;
1535 Variable _HeadArg = new Variable();
1536 Variable RestHeadArgs = new Variable();
1537 Variable CompiledHeadArg = new Variable();
1538 Variable RestCompiledHeadArgs = new Variable();
1539 Variable ArgName = new Variable();
1540 Variable RestArgUnifications = new Variable();
1541 Variable NumberCodes = new Variable();
1542 Variable NumberAtom = new Variable();
1543 Variable NextIndex = new Variable();
1544 foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs)))
1545 {
1546 foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
1547 {
1548 foreach (bool l4 in YP.unify(arg6, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(new Functor1(@"var", ArgName), new ListPair(CompiledHeadArg, Atom.NIL))), RestArgUnifications), Atom.NIL)))
1549 {
1550 foreach (bool l5 in YP.number_codes(Index, NumberCodes))
1551 {
1552 foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
1553 {
1554 foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1555 {
1556 foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
1557 {
1558 foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications))
1559 {
1560 yield return true;
1561 yield break;
1562 }
1563 }
1564 }
1565 }
1566 }
1567 }
1568 }
1569 }
1570 }
1571 }
1572
1573 public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
1574 {
1575 {
1576 object _HeadArgs = arg2;
1577 Variable ArgAssignmentsIn = new Variable();
1578 Variable DeclarationsIn = new Variable();
1579 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1580 {
1581 foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn))
1582 {
1583 foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn))
1584 {
1585 foreach (bool l5 in YP.unify(arg5, DeclarationsIn))
1586 {
1587 foreach (bool l6 in YP.unify(arg6, DeclarationsIn))
1588 {
1589 yield return true;
1590 yield break;
1591 }
1592 }
1593 }
1594 }
1595 }
1596 }
1597 {
1598 object HeadArgs = arg2;
1599 object ArgAssignmentsIn = arg3;
1600 object ArgAssignmentsOut = arg4;
1601 object DeclarationsIn = arg5;
1602 object DeclarationsOut = arg6;
1603 Variable VariableName = new Variable();
1604 Variable Var = new Variable();
1605 Variable RestVariableNames = new Variable();
1606 Variable ArgIndex1 = new Variable();
1607 Variable NumberCodes = new Variable();
1608 Variable NumberAtom = new Variable();
1609 Variable ArgName = new Variable();
1610 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames)))
1611 {
1612 foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
1613 {
1614 foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes))
1615 {
1616 foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
1617 {
1618 foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
1619 {
1620 foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1621 {
1622 yield return true;
1623 yield break;
1624 }
1625 }
1626 }
1627 }
1628 }
1629 }
1630 }
1631 {
1632 object HeadArgs = arg2;
1633 object ArgAssignmentsIn = arg3;
1634 object ArgAssignmentsOut = arg4;
1635 object DeclarationsIn = arg5;
1636 Variable VariableName = new Variable();
1637 Variable _Var = new Variable();
1638 Variable RestVariableNames = new Variable();
1639 Variable DeclarationsOut = new Variable();
1640 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames)))
1641 {
1642 foreach (bool l3 in YP.unify(arg6, new ListPair(new Functor3(@"declare", Atom.a(@"Variable"), VariableName, new Functor2(@"new", Atom.a(@"Variable"), Atom.NIL)), DeclarationsOut)))
1643 {
1644 foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
1645 {
1646 yield return true;
1647 yield break;
1648 }
1649 }
1650 }
1651 }
1652 }
1653
1654 public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3)
1655 {
1656 {
1657 Variable FirstHeadArgs = new Variable();
1658 Variable RestHeadArgs = new Variable();
1659 Variable x4 = new Variable();
1660 foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs)))
1661 {
1662 foreach (bool l3 in YP.unify(arg3, 1))
1663 {
1664 if (sameVariable(Var, FirstHeadArgs))
1665 {
1666 foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4))
1667 {
1668 goto cutIf1;
1669 }
1670 yield return false;
1671 cutIf1:
1672 yield break;
1673 }
1674 }
1675 }
1676 }
1677 {
1678 object Index = arg3;
1679 Variable x2 = new Variable();
1680 Variable RestHeadArgs = new Variable();
1681 Variable RestIndex = new Variable();
1682 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs)))
1683 {
1684 foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex))
1685 {
1686 foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex)))
1687 {
1688 yield return true;
1689 yield break;
1690 }
1691 }
1692 }
1693 }
1694 }
1695
1696 public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3)
1697 {
1698 {
1699 object A = arg1;
1700 object State = arg2;
1701 object PseudoCode = arg3;
1702 if (YP.var(A))
1703 {
1704 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode))
1705 {
1706 yield return true;
1707 yield break;
1708 }
1709 }
1710 }
1711 {
1712 object State = arg2;
1713 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1714 {
1715 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1716 {
1717 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1718 {
1719 yield return true;
1720 yield break;
1721 }
1722 }
1723 }
1724 }
1725 {
1726 object State = arg2;
1727 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1728 {
1729 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1730 {
1731 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1732 {
1733 yield return true;
1734 yield break;
1735 }
1736 }
1737 }
1738 }
1739 {
1740 object State = arg2;
1741 foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
1742 {
1743 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL))))
1744 {
1745 CompilerState.setCodeUsesYield(State);
1746 yield return true;
1747 yield break;
1748 }
1749 }
1750 }
1751 {
1752 object _State = arg2;
1753 Variable Name = new Variable();
1754 foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
1755 {
1756 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
1757 {
1758 yield return true;
1759 yield break;
1760 }
1761 }
1762 }
1763 {
1764 object State = arg2;
1765 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1766 {
1767 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
1768 {
1769 if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
1770 {
1771 yield return true;
1772 yield break;
1773 }
1774 }
1775 }
1776 }
1777 {
1778 object State = arg2;
1779 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1780 {
1781 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
1782 {
1783 if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
1784 {
1785 yield return true;
1786 yield break;
1787 }
1788 }
1789 }
1790 }
1791 {
1792 object State = arg2;
1793 foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
1794 {
1795 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
1796 {
1797 CompilerState.setCodeUsesYield(State);
1798 yield return true;
1799 yield break;
1800 }
1801 }
1802 }
1803 {
1804 object State = arg2;
1805 object PseudoCode = arg3;
1806 Variable A = new Variable();
1807 Variable B = new Variable();
1808 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
1809 {
1810 if (YP.var(A))
1811 {
1812 foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
1813 {
1814 yield return true;
1815 yield break;
1816 }
1817 }
1818 }
1819 }
1820 {
1821 object State = arg2;
1822 object PseudoCode = arg3;
1823 Variable A = new Variable();
1824 Variable T = new Variable();
1825 Variable B = new Variable();
1826 Variable C = new Variable();
1827 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C)))
1828 {
1829 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode))
1830 {
1831 yield return true;
1832 yield break;
1833 }
1834 }
1835 }
1836 {
1837 object State = arg2;
1838 object PseudoCode = arg3;
1839 Variable A = new Variable();
1840 Variable B = new Variable();
1841 Variable C = new Variable();
1842 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C)))
1843 {
1844 foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode))
1845 {
1846 yield return true;
1847 yield break;
1848 }
1849 }
1850 }
1851 {
1852 object State = arg2;
1853 Variable A = new Variable();
1854 Variable B = new Variable();
1855 Variable ACode = new Variable();
1856 Variable BCode = new Variable();
1857 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1858 {
1859 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL)))
1860 {
1861 if (CompilerState.isSemidetNoneOut(State, A))
1862 {
1863 foreach (bool l5 in compileFunctorCall(A, State, ACode))
1864 {
1865 foreach (bool l6 in compileRuleBody(B, State, BCode))
1866 {
1867 yield return true;
1868 yield break;
1869 }
1870 }
1871 }
1872 }
1873 }
1874 }
1875 {
1876 object State = arg2;
1877 object PseudoCode = arg3;
1878 Variable A = new Variable();
1879 Variable B = new Variable();
1880 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
1881 {
1882 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode))
1883 {
1884 yield return true;
1885 yield break;
1886 }
1887 }
1888 }
1889 {
1890 object State = arg2;
1891 object PseudoCode = arg3;
1892 Variable A = new Variable();
1893 Variable B = new Variable();
1894 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B)))
1895 {
1896 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode))
1897 {
1898 yield return true;
1899 yield break;
1900 }
1901 }
1902 }
1903 {
1904 object State = arg2;
1905 object PseudoCode = arg3;
1906 Variable A = new Variable();
1907 Variable T = new Variable();
1908 Variable B = new Variable();
1909 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B)))
1910 {
1911 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode))
1912 {
1913 yield return true;
1914 yield break;
1915 }
1916 }
1917 }
1918 {
1919 object State = arg2;
1920 object PseudoCode = arg3;
1921 Variable A = new Variable();
1922 Variable B = new Variable();
1923 Variable C = new Variable();
1924 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C)))
1925 {
1926 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode))
1927 {
1928 yield return true;
1929 yield break;
1930 }
1931 }
1932 }
1933 {
1934 object State = arg2;
1935 object PseudoCode = arg3;
1936 Variable A = new Variable();
1937 Variable ACode = new Variable();
1938 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A)))
1939 {
1940 foreach (bool l3 in compileRuleBody(A, State, ACode))
1941 {
1942 foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode))
1943 {
1944 yield return true;
1945 yield break;
1946 }
1947 }
1948 }
1949 }
1950 {
1951 object State = arg2;
1952 object PseudoCode = arg3;
1953 Variable Name = new Variable();
1954 Variable A = new Variable();
1955 Variable ACode = new Variable();
1956 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A)))
1957 {
1958 foreach (bool l3 in compileRuleBody(A, State, ACode))
1959 {
1960 foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode))
1961 {
1962 yield return true;
1963 yield break;
1964 }
1965 }
1966 }
1967 }
1968 {
1969 object _State = arg2;
1970 Variable x1 = new Variable();
1971 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1)))
1972 {
1973 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
1974 {
1975 yield return true;
1976 yield break;
1977 }
1978 }
1979 }
1980 {
1981 object State = arg2;
1982 object PseudoCode = arg3;
1983 Variable A = new Variable();
1984 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A)))
1985 {
1986 foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
1987 {
1988 yield return true;
1989 yield break;
1990 }
1991 }
1992 }
1993 {
1994 object State = arg2;
1995 Variable A = new Variable();
1996 Variable Term = new Variable();
1997 Variable B = new Variable();
1998 Variable ACode = new Variable();
1999 Variable TermCode = new Variable();
2000 Variable BCode = new Variable();
2001 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B)))
2002 {
2003 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(ACode, new ListPair(TermCode, Atom.NIL))), BCode), Atom.NIL)))
2004 {
2005 foreach (bool l4 in compileTerm(A, State, ACode))
2006 {
2007 foreach (bool l5 in compileExpression(Term, State, TermCode))
2008 {
2009 foreach (bool l6 in compileRuleBody(B, State, BCode))
2010 {
2011 yield return true;
2012 yield break;
2013 }
2014 }
2015 }
2016 }
2017 }
2018 }
2019 {
2020 object State = arg2;
2021 Variable A = new Variable();
2022 Variable B = new Variable();
2023 Variable ACode = new Variable();
2024 Variable BCode = new Variable();
2025 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2026 {
2027 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2028 {
2029 if (CompilerState.isDetNoneOut(State, A))
2030 {
2031 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2032 {
2033 foreach (bool l6 in compileRuleBody(B, State, BCode))
2034 {
2035 yield return true;
2036 yield break;
2037 }
2038 }
2039 }
2040 }
2041 }
2042 }
2043 {
2044 object State = arg2;
2045 Variable A = new Variable();
2046 Variable B = new Variable();
2047 Variable ACode = new Variable();
2048 Variable BCode = new Variable();
2049 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2050 {
2051 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
2052 {
2053 if (CompilerState.isSemidetNoneOut(State, A))
2054 {
2055 foreach (bool l5 in compileFunctorCall(A, State, ACode))
2056 {
2057 foreach (bool l6 in compileRuleBody(B, State, BCode))
2058 {
2059 yield return true;
2060 yield break;
2061 }
2062 }
2063 }
2064 }
2065 }
2066 }
2067 {
2068 object State = arg2;
2069 Variable ACode = new Variable();
2070 Variable B = new Variable();
2071 Variable BCode = new Variable();
2072 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
2073 {
2074 foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
2075 {
2076 foreach (bool l4 in compileRuleBody(B, State, BCode))
2077 {
2078 yield return true;
2079 yield break;
2080 }
2081 }
2082 }
2083 }
2084 {
2085 object State = arg2;
2086 Variable A = new Variable();
2087 Variable B = new Variable();
2088 Variable FunctionName = new Variable();
2089 Variable X1Code = new Variable();
2090 Variable X2Code = new Variable();
2091 Variable BCode = new Variable();
2092 Variable Name = new Variable();
2093 Variable X1 = new Variable();
2094 Variable X2 = new Variable();
2095 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2096 {
2097 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor2(@"call", FunctionName, new ListPair(X1Code, new ListPair(X2Code, Atom.NIL))), BCode), Atom.NIL)))
2098 {
2099 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL)))))
2100 {
2101 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
2102 {
2103 foreach (bool l6 in compileExpression(X1, State, X1Code))
2104 {
2105 foreach (bool l7 in compileExpression(X2, State, X2Code))
2106 {
2107 foreach (bool l8 in compileRuleBody(B, State, BCode))
2108 {
2109 yield return true;
2110 yield break;
2111 }
2112 }
2113 }
2114 }
2115 }
2116 }
2117 }
2118 }
2119 {
2120 object State = arg2;
2121 object PseudoCode = arg3;
2122 Variable A = new Variable();
2123 Variable B = new Variable();
2124 Variable C = new Variable();
2125 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
2126 {
2127 foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
2128 {
2129 yield return true;
2130 yield break;
2131 }
2132 }
2133 }
2134 {
2135 object State = arg2;
2136 object PseudoCode = arg3;
2137 Variable Template = new Variable();
2138 Variable Goal = new Variable();
2139 Variable Bag = new Variable();
2140 Variable B = new Variable();
2141 Variable TemplateCode = new Variable();
2142 Variable FindallAnswers = new Variable();
2143 Variable GoalAndAddCode = new Variable();
2144 Variable BagCode = new Variable();
2145 Variable BCode = new Variable();
2146 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B)))
2147 {
2148 foreach (bool l3 in compileTerm(Template, State, TemplateCode))
2149 {
2150 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers))
2151 {
2152 foreach (bool l5 in compileRuleBody(new Functor2(@",", Goal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
2153 {
2154 foreach (bool l6 in compileTerm(Bag, State, BagCode))
2155 {
2156 foreach (bool l7 in compileRuleBody(B, State, BCode))
2157 {
2158 foreach (bool l8 in append(new ListPair(new Functor3(@"declare", Atom.a(@"FindallAnswers"), FindallAnswers, new Functor2(@"new", Atom.a(@"FindallAnswers"), new ListPair(TemplateCode, Atom.NIL))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"result"), new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
2159 {
2160 yield return true;
2161 yield break;
2162 }
2163 }
2164 }
2165 }
2166 }
2167 }
2168 }
2169 }
2170 {
2171 object State = arg2;
2172 object PseudoCode = arg3;
2173 Variable Template = new Variable();
2174 Variable Goal = new Variable();
2175 Variable Bag = new Variable();
2176 Variable B = new Variable();
2177 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B)))
2178 {
2179 foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode))
2180 {
2181 yield return true;
2182 yield break;
2183 }
2184 }
2185 }
2186 {
2187 object State = arg2;
2188 object PseudoCode = arg3;
2189 Variable Template = new Variable();
2190 Variable Goal = new Variable();
2191 Variable Bag = new Variable();
2192 Variable B = new Variable();
2193 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B)))
2194 {
2195 foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode))
2196 {
2197 yield return true;
2198 yield break;
2199 }
2200 }
2201 }
2202 {
2203 object State = arg2;
2204 Variable A = new Variable();
2205 Variable B = new Variable();
2206 Variable ATermCode = new Variable();
2207 Variable BCode = new Variable();
2208 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B)))
2209 {
2210 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL)))
2211 {
2212 foreach (bool l4 in compileTerm(A, State, ATermCode))
2213 {
2214 foreach (bool l5 in compileRuleBody(B, State, BCode))
2215 {
2216 yield return true;
2217 yield break;
2218 }
2219 }
2220 }
2221 }
2222 }
2223 {
2224 object State = arg2;
2225 Variable A = new Variable();
2226 Variable B = new Variable();
2227 Variable ATermCode = new Variable();
2228 Variable BCode = new Variable();
2229 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"asserta", A), B)))
2230 {
2231 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2232 {
2233 foreach (bool l4 in compileTerm(A, State, ATermCode))
2234 {
2235 foreach (bool l5 in compileRuleBody(B, State, BCode))
2236 {
2237 yield return true;
2238 yield break;
2239 }
2240 }
2241 }
2242 }
2243 }
2244 {
2245 object State = arg2;
2246 Variable A = new Variable();
2247 Variable B = new Variable();
2248 Variable ATermCode = new Variable();
2249 Variable BCode = new Variable();
2250 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assertz", A), B)))
2251 {
2252 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
2253 {
2254 foreach (bool l4 in compileTerm(A, State, ATermCode))
2255 {
2256 foreach (bool l5 in compileRuleBody(B, State, BCode))
2257 {
2258 yield return true;
2259 yield break;
2260 }
2261 }
2262 }
2263 }
2264 }
2265 {
2266 object State = arg2;
2267 object PseudoCode = arg3;
2268 Variable A = new Variable();
2269 Variable B = new Variable();
2270 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assert", A), B)))
2271 {
2272 foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"assertz", A), B), State, PseudoCode))
2273 {
2274 yield return true;
2275 yield break;
2276 }
2277 }
2278 }
2279 {
2280 object State = arg2;
2281 Variable Goal = new Variable();
2282 Variable Catcher = new Variable();
2283 Variable Handler = new Variable();
2284 Variable B = new Variable();
2285 Variable CatchGoal = new Variable();
2286 Variable GoalTermCode = new Variable();
2287 Variable BCode = new Variable();
2288 Variable CatcherTermCode = new Variable();
2289 Variable HandlerAndBCode = new Variable();
2290 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"catch", Goal, Catcher, Handler), B)))
2291 {
2292 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3(@"declare", Atom.a(@"YP.Catch"), CatchGoal, new Functor2(@"new", Atom.a(@"YP.Catch"), new ListPair(new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2(@"foreach", new Functor1(@"var", CatchGoal), BCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", CatchGoal), Atom.a(@"unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL)))))
2293 {
2294 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal))
2295 {
2296 foreach (bool l5 in compileTerm(Goal, State, GoalTermCode))
2297 {
2298 foreach (bool l6 in compileTerm(Catcher, State, CatcherTermCode))
2299 {
2300 foreach (bool l7 in compileRuleBody(B, State, BCode))
2301 {
2302 foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode))
2303 {
2304 yield return true;
2305 yield break;
2306 }
2307 }
2308 }
2309 }
2310 }
2311 }
2312 }
2313 }
2314 {
2315 object State = arg2;
2316 Variable A = new Variable();
2317 Variable B = new Variable();
2318 Variable ACode = new Variable();
2319 Variable BCode = new Variable();
2320 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
2321 {
2322 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL)))
2323 {
2324 foreach (bool l4 in compileFunctorCall(A, State, ACode))
2325 {
2326 foreach (bool l5 in compileRuleBody(B, State, BCode))
2327 {
2328 yield return true;
2329 yield break;
2330 }
2331 }
2332 }
2333 }
2334 }
2335 {
2336 object State = arg2;
2337 object PseudoCode = arg3;
2338 Variable A = new Variable();
2339 Variable B = new Variable();
2340 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2341 {
2342 if (YP.var(A))
2343 {
2344 foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode))
2345 {
2346 yield return true;
2347 yield break;
2348 }
2349 }
2350 }
2351 }
2352 {
2353 object State = arg2;
2354 Variable A = new Variable();
2355 Variable T = new Variable();
2356 Variable B = new Variable();
2357 Variable CutIfLabel = new Variable();
2358 Variable Code = new Variable();
2359 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B)))
2360 {
2361 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL)))
2362 {
2363 foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel))
2364 {
2365 foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code))
2366 {
2367 yield return true;
2368 yield break;
2369 }
2370 }
2371 }
2372 }
2373 }
2374 {
2375 object State = arg2;
2376 object PseudoCode = arg3;
2377 Variable A = new Variable();
2378 Variable B = new Variable();
2379 Variable ACode = new Variable();
2380 Variable BCode = new Variable();
2381 foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
2382 {
2383 foreach (bool l3 in compileRuleBody(A, State, ACode))
2384 {
2385 foreach (bool l4 in compileRuleBody(B, State, BCode))
2386 {
2387 foreach (bool l5 in append(ACode, BCode, PseudoCode))
2388 {
2389 yield return true;
2390 yield break;
2391 }
2392 }
2393 }
2394 }
2395 }
2396 {
2397 object A = arg1;
2398 object State = arg2;
2399 object PseudoCode = arg3;
2400 foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode))
2401 {
2402 yield return true;
2403 yield break;
2404 }
2405 }
2406 }
2407
2408 public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode)
2409 {
2410 {
2411 Variable TemplateCode = new Variable();
2412 Variable GoalTermCode = new Variable();
2413 Variable UnqualifiedGoal = new Variable();
2414 Variable BagofAnswers = new Variable();
2415 Variable GoalAndAddCode = new Variable();
2416 Variable BagCode = new Variable();
2417 Variable BCode = new Variable();
2418 foreach (bool l2 in compileTerm(Template, State, TemplateCode))
2419 {
2420 foreach (bool l3 in compileTerm(Goal, State, GoalTermCode))
2421 {
2422 foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
2423 {
2424 foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers))
2425 {
2426 foreach (bool l6 in compileRuleBody(new Functor2(@",", UnqualifiedGoal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
2427 {
2428 foreach (bool l7 in compileTerm(Bag, State, BagCode))
2429 {
2430 foreach (bool l8 in compileRuleBody(B, State, BCode))
2431 {
2432 foreach (bool l9 in append(new ListPair(new Functor3(@"declare", Atom.a(@"BagofAnswers"), BagofAnswers, new Functor2(@"new", Atom.a(@"BagofAnswers"), new ListPair(TemplateCode, new ListPair(GoalTermCode, Atom.NIL)))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), ResultMethod, new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
2433 {
2434 yield return true;
2435 yield break;
2436 }
2437 }
2438 }
2439 }
2440 }
2441 }
2442 }
2443 }
2444 }
2445 }
2446
2447 public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2)
2448 {
2449 {
2450 object Goal = arg1;
2451 foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal)))
2452 {
2453 if (YP.var(Goal))
2454 {
2455 yield return true;
2456 yield break;
2457 }
2458 }
2459 }
2460 {
2461 object UnqualifiedGoal = arg2;
2462 Variable x1 = new Variable();
2463 Variable Goal = new Variable();
2464 foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal)))
2465 {
2466 foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
2467 {
2468 yield return true;
2469 yield break;
2470 }
2471 }
2472 }
2473 {
2474 Variable UnqualifiedGoal = new Variable();
2475 foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal))
2476 {
2477 foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal))
2478 {
2479 yield return true;
2480 yield break;
2481 }
2482 }
2483 }
2484 }
2485
2486 public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
2487 {
2488 {
2489 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:=")))
2490 {
2491 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal")))
2492 {
2493 yield return true;
2494 yield break;
2495 }
2496 }
2497 }
2498 {
2499 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\=")))
2500 {
2501 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual")))
2502 {
2503 yield return true;
2504 yield break;
2505 }
2506 }
2507 }
2508 {
2509 foreach (bool l2 in YP.unify(arg1, Atom.a(@">")))
2510 {
2511 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan")))
2512 {
2513 yield return true;
2514 yield break;
2515 }
2516 }
2517 }
2518 {
2519 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<")))
2520 {
2521 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan")))
2522 {
2523 yield return true;
2524 yield break;
2525 }
2526 }
2527 }
2528 {
2529 foreach (bool l2 in YP.unify(arg1, Atom.a(@">=")))
2530 {
2531 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual")))
2532 {
2533 yield return true;
2534 yield break;
2535 }
2536 }
2537 }
2538 {
2539 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<")))
2540 {
2541 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual")))
2542 {
2543 yield return true;
2544 yield break;
2545 }
2546 }
2547 }
2548 }
2549
2550 public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object PseudoCode)
2551 {
2552 {
2553 Variable FunctorName = new Variable();
2554 Variable FunctorArgs = new Variable();
2555 Variable x6 = new Variable();
2556 Variable Arity = new Variable();
2557 Variable CompiledArgs = new Variable();
2558 Variable FunctionName = new Variable();
2559 foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs)))
2560 {
2561 foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
2562 {
2563 foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
2564 {
2565 foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
2566 {
2567 if (YP.termEqual(FunctionName, Atom.NIL))
2568 {
2569 foreach (bool l7 in YP.unify(PseudoCode, new Functor2(@"call", Atom.a(@"YP.matchDynamic"), new ListPair(new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", FunctorName), Atom.NIL)), new ListPair(new Functor1(@"objectArray", CompiledArgs), Atom.NIL)))))
2570 {
2571 yield return true;
2572 yield break;
2573 }
2574 goto cutIf1;
2575 }
2576 foreach (bool l6 in YP.unify(PseudoCode, new Functor2(@"call", FunctionName, CompiledArgs)))
2577 {
2578 yield return true;
2579 yield break;
2580 }
2581 cutIf1:
2582 { }
2583 }
2584 }
2585 }
2586 }
2587 }
2588 }
2589
2590 public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4)
2591 {
2592 {
2593 object x1 = arg1;
2594 object Name = arg2;
2595 object Arity = arg3;
2596 object FunctionName = arg4;
2597 foreach (bool l2 in functorCallYPFunctionName(Name, Arity, FunctionName))
2598 {
2599 yield return true;
2600 yield break;
2601 }
2602 }
2603 {
2604 object State = arg1;
2605 object Arity = arg3;
2606 Variable Name = new Variable();
2607 foreach (bool l2 in YP.unify(arg2, Name))
2608 {
2609 foreach (bool l3 in YP.unify(arg4, Name))
2610 {
2611 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
2612 {
2613 yield return true;
2614 yield break;
2615 }
2616 }
2617 }
2618 }
2619 {
2620 object _State = arg1;
2621 object _Arity = arg3;
2622 Variable Name = new Variable();
2623 foreach (bool l2 in YP.unify(arg2, Name))
2624 {
2625 foreach (bool l3 in YP.unify(arg4, Name))
2626 {
2627 foreach (bool l4 in Atom.module(Name, Atom.a(@"")))
2628 {
2629 yield return true;
2630 yield break;
2631 }
2632 }
2633 }
2634 }
2635 {
2636 object _State = arg1;
2637 object Name = arg2;
2638 object Arity = arg3;
2639 foreach (bool l2 in YP.unify(arg4, Atom.NIL))
2640 {
2641 foreach (bool l3 in Atom.module(Name, Atom.NIL))
2642 {
2643 yield return true;
2644 yield break;
2645 }
2646 }
2647 }
2648 {
2649 object _State = arg1;
2650 object Name = arg2;
2651 object Arity = arg3;
2652 object x4 = arg4;
2653 Variable Module = new Variable();
2654 Variable Message = new Variable();
2655 foreach (bool l2 in Atom.module(Name, Module))
2656 {
2657 foreach (bool l3 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message))
2658 {
2659 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message));
2660 yield return true;
2661 yield break;
2662 }
2663 }
2664 }
2665 {
2666 object _State = arg1;
2667 object Name = arg2;
2668 object _Arity = arg3;
2669 object x4 = arg4;
2670 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), Name), Atom.a(@"Term is not callable")));
2671 yield return true;
2672 yield break;
2673 }
2674 }
2675
2676 public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3)
2677 {
2678 {
2679 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=")))
2680 {
2681 foreach (bool l3 in YP.unify(arg2, 2))
2682 {
2683 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify")))
2684 {
2685 yield return true;
2686 yield break;
2687 }
2688 }
2689 }
2690 }
2691 {
2692 foreach (bool l2 in YP.unify(arg1, Atom.a(@"=..")))
2693 {
2694 foreach (bool l3 in YP.unify(arg2, 2))
2695 {
2696 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ")))
2697 {
2698 yield return true;
2699 yield break;
2700 }
2701 }
2702 }
2703 }
2704 {
2705 foreach (bool l2 in YP.unify(arg1, Atom.a(@"var")))
2706 {
2707 foreach (bool l3 in YP.unify(arg2, 1))
2708 {
2709 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var")))
2710 {
2711 yield return true;
2712 yield break;
2713 }
2714 }
2715 }
2716 }
2717 {
2718 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar")))
2719 {
2720 foreach (bool l3 in YP.unify(arg2, 1))
2721 {
2722 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar")))
2723 {
2724 yield return true;
2725 yield break;
2726 }
2727 }
2728 }
2729 }
2730 {
2731 foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg")))
2732 {
2733 foreach (bool l3 in YP.unify(arg2, 3))
2734 {
2735 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg")))
2736 {
2737 yield return true;
2738 yield break;
2739 }
2740 }
2741 }
2742 }
2743 {
2744 foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor")))
2745 {
2746 foreach (bool l3 in YP.unify(arg2, 3))
2747 {
2748 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor")))
2749 {
2750 yield return true;
2751 yield break;
2752 }
2753 }
2754 }
2755 }
2756 {
2757 foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat")))
2758 {
2759 foreach (bool l3 in YP.unify(arg2, 0))
2760 {
2761 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat")))
2762 {
2763 yield return true;
2764 yield break;
2765 }
2766 }
2767 }
2768 }
2769 {
2770 foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code")))
2771 {
2772 foreach (bool l3 in YP.unify(arg2, 1))
2773 {
2774 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code")))
2775 {
2776 yield return true;
2777 yield break;
2778 }
2779 }
2780 }
2781 }
2782 {
2783 foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op")))
2784 {
2785 foreach (bool l3 in YP.unify(arg2, 3))
2786 {
2787 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op")))
2788 {
2789 yield return true;
2790 yield break;
2791 }
2792 }
2793 }
2794 }
2795 {
2796 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length")))
2797 {
2798 foreach (bool l3 in YP.unify(arg2, 2))
2799 {
2800 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length")))
2801 {
2802 yield return true;
2803 yield break;
2804 }
2805 }
2806 }
2807 }
2808 {
2809 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat")))
2810 {
2811 foreach (bool l3 in YP.unify(arg2, 3))
2812 {
2813 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat")))
2814 {
2815 yield return true;
2816 yield break;
2817 }
2818 }
2819 }
2820 }
2821 {
2822 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom")))
2823 {
2824 foreach (bool l3 in YP.unify(arg2, 5))
2825 {
2826 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom")))
2827 {
2828 yield return true;
2829 yield break;
2830 }
2831 }
2832 }
2833 }
2834 {
2835 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes")))
2836 {
2837 foreach (bool l3 in YP.unify(arg2, 2))
2838 {
2839 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes")))
2840 {
2841 yield return true;
2842 yield break;
2843 }
2844 }
2845 }
2846 }
2847 {
2848 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes")))
2849 {
2850 foreach (bool l3 in YP.unify(arg2, 2))
2851 {
2852 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes")))
2853 {
2854 yield return true;
2855 yield break;
2856 }
2857 }
2858 }
2859 }
2860 {
2861 foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term")))
2862 {
2863 foreach (bool l3 in YP.unify(arg2, 2))
2864 {
2865 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term")))
2866 {
2867 yield return true;
2868 yield break;
2869 }
2870 }
2871 }
2872 }
2873 {
2874 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort")))
2875 {
2876 foreach (bool l3 in YP.unify(arg2, 2))
2877 {
2878 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort")))
2879 {
2880 yield return true;
2881 yield break;
2882 }
2883 }
2884 }
2885 }
2886 {
2887 // Manually included : script_event for callback to LSL/C#
2888
2889 //object x1 = arg1;
2890 foreach (bool l2 in YP.unify(arg1, Atom.a(@"script_event")))
2891 {
2892 foreach (bool l3 in YP.unify(arg2, 2))
2893 {
2894 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.script_event")))
2895 {
2896 yield return true;
2897 yield break;
2898 }
2899 }
2900 }
2901 }
2902 {
2903 foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl")))
2904 {
2905 foreach (bool l3 in YP.unify(arg2, 0))
2906 {
2907 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl")))
2908 {
2909 yield return true;
2910 yield break;
2911 }
2912 }
2913 }
2914 }
2915 {
2916 foreach (bool l2 in YP.unify(arg1, Atom.a(@"write")))
2917 {
2918 foreach (bool l3 in YP.unify(arg2, 1))
2919 {
2920 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write")))
2921 {
2922 yield return true;
2923 yield break;
2924 }
2925 }
2926 }
2927 }
2928 {
2929 foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code")))
2930 {
2931 foreach (bool l3 in YP.unify(arg2, 1))
2932 {
2933 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code")))
2934 {
2935 yield return true;
2936 yield break;
2937 }
2938 }
2939 }
2940 }
2941 {
2942 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom")))
2943 {
2944 foreach (bool l3 in YP.unify(arg2, 1))
2945 {
2946 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom")))
2947 {
2948 yield return true;
2949 yield break;
2950 }
2951 }
2952 }
2953 }
2954 {
2955 foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer")))
2956 {
2957 foreach (bool l3 in YP.unify(arg2, 1))
2958 {
2959 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer")))
2960 {
2961 yield return true;
2962 yield break;
2963 }
2964 }
2965 }
2966 }
2967 {
2968 foreach (bool l2 in YP.unify(arg1, Atom.a(@"float")))
2969 {
2970 foreach (bool l3 in YP.unify(arg2, 1))
2971 {
2972 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.isFloat")))
2973 {
2974 yield return true;
2975 yield break;
2976 }
2977 }
2978 }
2979 }
2980 {
2981 foreach (bool l2 in YP.unify(arg1, Atom.a(@"number")))
2982 {
2983 foreach (bool l3 in YP.unify(arg2, 1))
2984 {
2985 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number")))
2986 {
2987 yield return true;
2988 yield break;
2989 }
2990 }
2991 }
2992 }
2993 {
2994 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic")))
2995 {
2996 foreach (bool l3 in YP.unify(arg2, 1))
2997 {
2998 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic")))
2999 {
3000 yield return true;
3001 yield break;
3002 }
3003 }
3004 }
3005 }
3006 {
3007 foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound")))
3008 {
3009 foreach (bool l3 in YP.unify(arg2, 1))
3010 {
3011 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound")))
3012 {
3013 yield return true;
3014 yield break;
3015 }
3016 }
3017 }
3018 }
3019 {
3020 foreach (bool l2 in YP.unify(arg1, Atom.a(@"==")))
3021 {
3022 foreach (bool l3 in YP.unify(arg2, 2))
3023 {
3024 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual")))
3025 {
3026 yield return true;
3027 yield break;
3028 }
3029 }
3030 }
3031 }
3032 {
3033 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\==")))
3034 {
3035 foreach (bool l3 in YP.unify(arg2, 2))
3036 {
3037 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual")))
3038 {
3039 yield return true;
3040 yield break;
3041 }
3042 }
3043 }
3044 }
3045 {
3046 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<")))
3047 {
3048 foreach (bool l3 in YP.unify(arg2, 2))
3049 {
3050 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan")))
3051 {
3052 yield return true;
3053 yield break;
3054 }
3055 }
3056 }
3057 }
3058 {
3059 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<")))
3060 {
3061 foreach (bool l3 in YP.unify(arg2, 2))
3062 {
3063 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual")))
3064 {
3065 yield return true;
3066 yield break;
3067 }
3068 }
3069 }
3070 }
3071 {
3072 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>")))
3073 {
3074 foreach (bool l3 in YP.unify(arg2, 2))
3075 {
3076 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan")))
3077 {
3078 yield return true;
3079 yield break;
3080 }
3081 }
3082 }
3083 }
3084 {
3085 foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>=")))
3086 {
3087 foreach (bool l3 in YP.unify(arg2, 2))
3088 {
3089 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual")))
3090 {
3091 yield return true;
3092 yield break;
3093 }
3094 }
3095 }
3096 }
3097 {
3098 foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw")))
3099 {
3100 foreach (bool l3 in YP.unify(arg2, 1))
3101 {
3102 foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
3103 {
3104 yield return true;
3105 yield break;
3106 }
3107 }
3108 }
3109 }
3110 }
3111
3112 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
3113 {
3114 {
3115 object Term = arg1;
3116 object State = arg2;
3117 Variable VariableName = new Variable();
3118 foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName)))
3119 {
3120 if (YP.var(Term))
3121 {
3122 foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName))
3123 {
3124 yield return true;
3125 yield break;
3126 }
3127 }
3128 }
3129 }
3130 {
3131 object _State = arg2;
3132 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3133 {
3134 foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL"))))
3135 {
3136 yield return true;
3137 yield break;
3138 }
3139 }
3140 }
3141 {
3142 object Term = arg1;
3143 object State = arg2;
3144 object Code = arg3;
3145 Variable ModuleCode = new Variable();
3146 if (YP.atom(Term))
3147 {
3148 foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
3149 {
3150 foreach (bool l4 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), new ListPair(ModuleCode, Atom.NIL)))))
3151 {
3152 yield return true;
3153 yield break;
3154 }
3155 goto cutIf1;
3156 }
3157 foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL))))
3158 {
3159 yield return true;
3160 yield break;
3161 }
3162 cutIf1:
3163 { }
3164 }
3165 }
3166 {
3167 object State = arg2;
3168 Variable First = new Variable();
3169 Variable Rest = new Variable();
3170 Variable Arg1 = new Variable();
3171 Variable Arg2 = new Variable();
3172 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3173 {
3174 foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3175 {
3176 foreach (bool l4 in compileTerm(First, State, Arg1))
3177 {
3178 foreach (bool l5 in compileTerm(Rest, State, Arg2))
3179 {
3180 yield return true;
3181 yield break;
3182 }
3183 }
3184 }
3185 }
3186 }
3187 {
3188 object Term = arg1;
3189 object State = arg2;
3190 object Result = arg3;
3191 Variable Name = new Variable();
3192 Variable TermArgs = new Variable();
3193 Variable x6 = new Variable();
3194 Variable Arity = new Variable();
3195 Variable ModuleCode = new Variable();
3196 Variable NameCode = new Variable();
3197 Variable X1 = new Variable();
3198 Variable Arg1 = new Variable();
3199 Variable X2 = new Variable();
3200 Variable Arg2 = new Variable();
3201 Variable X3 = new Variable();
3202 Variable Arg3 = new Variable();
3203 Variable Args = new Variable();
3204 foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs)))
3205 {
3206 if (YP.termEqual(TermArgs, Atom.NIL))
3207 {
3208 foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name)))
3209 {
3210 yield return true;
3211 yield break;
3212 }
3213 goto cutIf2;
3214 }
3215 foreach (bool l3 in YP.functor(Term, x6, Arity))
3216 {
3217 foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
3218 {
3219 foreach (bool l5 in YP.unify(NameCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Name), new ListPair(ModuleCode, Atom.NIL)))))
3220 {
3221 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3222 {
3223 foreach (bool l7 in compileTerm(X1, State, Arg1))
3224 {
3225 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3226 {
3227 yield return true;
3228 yield break;
3229 }
3230 }
3231 goto cutIf4;
3232 }
3233 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3234 {
3235 foreach (bool l7 in compileTerm(X1, State, Arg1))
3236 {
3237 foreach (bool l8 in compileTerm(X2, State, Arg2))
3238 {
3239 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3240 {
3241 yield return true;
3242 yield break;
3243 }
3244 }
3245 }
3246 goto cutIf5;
3247 }
3248 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3249 {
3250 foreach (bool l7 in compileTerm(X1, State, Arg1))
3251 {
3252 foreach (bool l8 in compileTerm(X2, State, Arg2))
3253 {
3254 foreach (bool l9 in compileTerm(X3, State, Arg3))
3255 {
3256 foreach (bool l10 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
3257 {
3258 yield return true;
3259 yield break;
3260 }
3261 }
3262 }
3263 }
3264 }
3265 foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
3266 {
3267 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3268 {
3269 yield return true;
3270 yield break;
3271 }
3272 }
3273 cutIf5:
3274 cutIf4:
3275 { }
3276 }
3277 goto cutIf3;
3278 }
3279 foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name)))
3280 {
3281 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3282 {
3283 foreach (bool l6 in compileTerm(X1, State, Arg1))
3284 {
3285 foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
3286 {
3287 yield return true;
3288 yield break;
3289 }
3290 }
3291 goto cutIf6;
3292 }
3293 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3294 {
3295 foreach (bool l6 in compileTerm(X1, State, Arg1))
3296 {
3297 foreach (bool l7 in compileTerm(X2, State, Arg2))
3298 {
3299 foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
3300 {
3301 yield return true;
3302 yield break;
3303 }
3304 }
3305 }
3306 goto cutIf7;
3307 }
3308 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
3309 {
3310 foreach (bool l6 in compileTerm(X1, State, Arg1))
3311 {
3312 foreach (bool l7 in compileTerm(X2, State, Arg2))
3313 {
3314 foreach (bool l8 in compileTerm(X3, State, Arg3))
3315 {
3316 foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
3317 {
3318 yield return true;
3319 yield break;
3320 }
3321 }
3322 }
3323 }
3324 }
3325 foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
3326 {
3327 foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
3328 {
3329 yield return true;
3330 yield break;
3331 }
3332 }
3333 cutIf7:
3334 cutIf6:
3335 { }
3336 }
3337 cutIf3:
3338 { }
3339 }
3340 cutIf2:
3341 { }
3342 }
3343 }
3344 }
3345
3346 public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode)
3347 {
3348 {
3349 if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
3350 {
3351 foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL))))
3352 {
3353 yield return true;
3354 yield break;
3355 }
3356 }
3357 }
3358 }
3359
3360 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
3361 {
3362 {
3363 object _State = arg2;
3364 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3365 {
3366 foreach (bool l3 in YP.unify(arg3, Atom.NIL))
3367 {
3368 yield return true;
3369 yield break;
3370 }
3371 }
3372 }
3373 {
3374 object State = arg2;
3375 Variable First = new Variable();
3376 Variable Rest = new Variable();
3377 Variable FirstResult = new Variable();
3378 Variable RestResults = new Variable();
3379 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3380 {
3381 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
3382 {
3383 foreach (bool l4 in compileTerm(First, State, FirstResult))
3384 {
3385 foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults))
3386 {
3387 yield return true;
3388 yield break;
3389 }
3390 }
3391 }
3392 }
3393 }
3394 }
3395
3396 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
3397 {
3398 {
3399 Variable Name = new Variable();
3400 Variable TermArgs = new Variable();
3401 Variable X1 = new Variable();
3402 Variable FunctionName = new Variable();
3403 Variable Arg1 = new Variable();
3404 Variable x9 = new Variable();
3405 Variable X2 = new Variable();
3406 Variable Arg2 = new Variable();
3407 Variable x12 = new Variable();
3408 Variable Arity = new Variable();
3409 if (YP.nonvar(Term))
3410 {
3411 foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
3412 {
3413 if (YP.atom(Name))
3414 {
3415 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
3416 {
3417 foreach (bool l6 in unaryFunction(Name, FunctionName))
3418 {
3419 foreach (bool l7 in compileExpression(X1, State, Arg1))
3420 {
3421 foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL))))
3422 {
3423 yield return true;
3424 yield break;
3425 }
3426 }
3427 goto cutIf1;
3428 }
3429 }
3430 foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
3431 {
3432 foreach (bool l6 in compileTerm(Term, State, Result))
3433 {
3434 yield return true;
3435 yield break;
3436 }
3437 goto cutIf2;
3438 }
3439 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
3440 {
3441 foreach (bool l6 in binaryFunction(Name, FunctionName))
3442 {
3443 foreach (bool l7 in compileExpression(X1, State, Arg1))
3444 {
3445 foreach (bool l8 in compileExpression(X2, State, Arg2))
3446 {
3447 foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
3448 {
3449 yield return true;
3450 yield break;
3451 }
3452 }
3453 }
3454 goto cutIf3;
3455 }
3456 }
3457 foreach (bool l5 in YP.functor(Term, x12, Arity))
3458 {
3459 YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Not an expression function")));
3460 yield return false;
3461 }
3462 cutIf3:
3463 cutIf2:
3464 cutIf1:
3465 { }
3466 }
3467 }
3468 }
3469 }
3470 {
3471 foreach (bool l2 in compileTerm(Term, State, Result))
3472 {
3473 yield return true;
3474 yield break;
3475 }
3476 }
3477 }
3478
3479 public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
3480 {
3481 {
3482 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3483 {
3484 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate")))
3485 {
3486 yield return true;
3487 yield break;
3488 }
3489 }
3490 }
3491 {
3492 foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs")))
3493 {
3494 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs")))
3495 {
3496 yield return true;
3497 yield break;
3498 }
3499 }
3500 }
3501 {
3502 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign")))
3503 {
3504 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign")))
3505 {
3506 yield return true;
3507 yield break;
3508 }
3509 }
3510 }
3511 {
3512 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3513 {
3514 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor")))
3515 {
3516 yield return true;
3517 yield break;
3518 }
3519 }
3520 }
3521 {
3522 foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate")))
3523 {
3524 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate")))
3525 {
3526 yield return true;
3527 yield break;
3528 }
3529 }
3530 }
3531 {
3532 foreach (bool l2 in YP.unify(arg1, Atom.a(@"round")))
3533 {
3534 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round")))
3535 {
3536 yield return true;
3537 yield break;
3538 }
3539 }
3540 }
3541 {
3542 foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
3543 {
3544 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling")))
3545 {
3546 yield return true;
3547 yield break;
3548 }
3549 }
3550 }
3551 {
3552 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin")))
3553 {
3554 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin")))
3555 {
3556 yield return true;
3557 yield break;
3558 }
3559 }
3560 }
3561 {
3562 foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos")))
3563 {
3564 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos")))
3565 {
3566 yield return true;
3567 yield break;
3568 }
3569 }
3570 }
3571 {
3572 foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan")))
3573 {
3574 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan")))
3575 {
3576 yield return true;
3577 yield break;
3578 }
3579 }
3580 }
3581 {
3582 foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp")))
3583 {
3584 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp")))
3585 {
3586 yield return true;
3587 yield break;
3588 }
3589 }
3590 }
3591 {
3592 foreach (bool l2 in YP.unify(arg1, Atom.a(@"log")))
3593 {
3594 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log")))
3595 {
3596 yield return true;
3597 yield break;
3598 }
3599 }
3600 }
3601 {
3602 foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt")))
3603 {
3604 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt")))
3605 {
3606 yield return true;
3607 yield break;
3608 }
3609 }
3610 }
3611 {
3612 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\")))
3613 {
3614 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement")))
3615 {
3616 yield return true;
3617 yield break;
3618 }
3619 }
3620 }
3621 }
3622
3623 public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
3624 {
3625 {
3626 foreach (bool l2 in YP.unify(arg1, Atom.a(@"+")))
3627 {
3628 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add")))
3629 {
3630 yield return true;
3631 yield break;
3632 }
3633 }
3634 }
3635 {
3636 foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
3637 {
3638 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract")))
3639 {
3640 yield return true;
3641 yield break;
3642 }
3643 }
3644 }
3645 {
3646 foreach (bool l2 in YP.unify(arg1, Atom.a(@"*")))
3647 {
3648 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply")))
3649 {
3650 yield return true;
3651 yield break;
3652 }
3653 }
3654 }
3655 {
3656 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/")))
3657 {
3658 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide")))
3659 {
3660 yield return true;
3661 yield break;
3662 }
3663 }
3664 }
3665 {
3666 foreach (bool l2 in YP.unify(arg1, Atom.a(@"//")))
3667 {
3668 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide")))
3669 {
3670 yield return true;
3671 yield break;
3672 }
3673 }
3674 }
3675 {
3676 foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod")))
3677 {
3678 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod")))
3679 {
3680 yield return true;
3681 yield break;
3682 }
3683 }
3684 }
3685 {
3686 foreach (bool l2 in YP.unify(arg1, Atom.a(@"**")))
3687 {
3688 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow")))
3689 {
3690 yield return true;
3691 yield break;
3692 }
3693 }
3694 }
3695 {
3696 foreach (bool l2 in YP.unify(arg1, Atom.a(@">>")))
3697 {
3698 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight")))
3699 {
3700 yield return true;
3701 yield break;
3702 }
3703 }
3704 }
3705 {
3706 foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<")))
3707 {
3708 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft")))
3709 {
3710 yield return true;
3711 yield break;
3712 }
3713 }
3714 }
3715 {
3716 foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\")))
3717 {
3718 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd")))
3719 {
3720 yield return true;
3721 yield break;
3722 }
3723 }
3724 }
3725 {
3726 foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/")))
3727 {
3728 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr")))
3729 {
3730 yield return true;
3731 yield break;
3732 }
3733 }
3734 }
3735 {
3736 foreach (bool l2 in YP.unify(arg1, Atom.a(@"min")))
3737 {
3738 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min")))
3739 {
3740 yield return true;
3741 yield break;
3742 }
3743 }
3744 }
3745 {
3746 foreach (bool l2 in YP.unify(arg1, Atom.a(@"max")))
3747 {
3748 foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max")))
3749 {
3750 yield return true;
3751 yield break;
3752 }
3753 }
3754 }
3755 }
3756
3757 public static void convertFunctionCSharp(object arg1)
3758 {
3759 {
3760 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
3761 {
3762 YP.write(Atom.a(@"public class YPInnerClass {}"));
3763 YP.nl();
3764 YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
3765 YP.nl();
3766 YP.nl();
3767 return;
3768 }
3769 }
3770 {
3771 Variable ReturnType = new Variable();
3772 Variable Name = new Variable();
3773 Variable ArgList = new Variable();
3774 Variable Body = new Variable();
3775 Variable Level = new Variable();
3776 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body })))
3777 {
3778 YP.write(Atom.a(@"public static "));
3779 YP.write(ReturnType);
3780 YP.write(Atom.a(@" "));
3781 YP.write(Name);
3782 YP.write(Atom.a(@"("));
3783 convertArgListCSharp(ArgList);
3784 YP.write(Atom.a(@") {"));
3785 YP.nl();
3786 foreach (bool l3 in YP.unify(Level, 1))
3787 {
3788 convertStatementListCSharp(Body, Level);
3789 YP.write(Atom.a(@"}"));
3790 YP.nl();
3791 YP.nl();
3792 return;
3793 }
3794 }
3795 }
3796 }
3797
3798 public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2)
3799 {
3800 {
3801 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
3802 {
3803 yield return true;
3804 yield break;
3805 }
3806 }
3807 }
3808
3809 public static void convertStatementListCSharp(object arg1, object Level)
3810 {
3811 {
3812 Variable Name = new Variable();
3813 Variable Body = new Variable();
3814 Variable RestStatements = new Variable();
3815 Variable NewStatements = new Variable();
3816 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
3817 {
3818 foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements))
3819 {
3820 convertStatementListCSharp(NewStatements, Level);
3821 return;
3822 }
3823 }
3824 }
3825 {
3826 Variable Type = new Variable();
3827 Variable Name = new Variable();
3828 Variable Expression = new Variable();
3829 Variable RestStatements = new Variable();
3830 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements)))
3831 {
3832 convertIndentationCSharp(Level);
3833 YP.write(Type);
3834 YP.write(Atom.a(@" "));
3835 YP.write(Name);
3836 YP.write(Atom.a(@" = "));
3837 convertExpressionCSharp(Expression);
3838 YP.write(Atom.a(@";"));
3839 YP.nl();
3840 convertStatementListCSharp(RestStatements, Level);
3841 return;
3842 }
3843 }
3844 {
3845 Variable Name = new Variable();
3846 Variable Expression = new Variable();
3847 Variable RestStatements = new Variable();
3848 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
3849 {
3850 convertIndentationCSharp(Level);
3851 YP.write(Name);
3852 YP.write(Atom.a(@" = "));
3853 convertExpressionCSharp(Expression);
3854 YP.write(Atom.a(@";"));
3855 YP.nl();
3856 convertStatementListCSharp(RestStatements, Level);
3857 return;
3858 }
3859 }
3860 {
3861 Variable RestStatements = new Variable();
3862 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
3863 {
3864 convertIndentationCSharp(Level);
3865 YP.write(Atom.a(@"yield return true;"));
3866 YP.nl();
3867 convertStatementListCSharp(RestStatements, Level);
3868 return;
3869 }
3870 }
3871 {
3872 Variable RestStatements = new Variable();
3873 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
3874 {
3875 convertIndentationCSharp(Level);
3876 YP.write(Atom.a(@"yield return false;"));
3877 YP.nl();
3878 convertStatementListCSharp(RestStatements, Level);
3879 return;
3880 }
3881 }
3882 {
3883 Variable RestStatements = new Variable();
3884 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
3885 {
3886 convertIndentationCSharp(Level);
3887 YP.write(Atom.a(@"yield break;"));
3888 YP.nl();
3889 convertStatementListCSharp(RestStatements, Level);
3890 return;
3891 }
3892 }
3893 {
3894 Variable RestStatements = new Variable();
3895 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
3896 {
3897 convertIndentationCSharp(Level);
3898 YP.write(Atom.a(@"return;"));
3899 YP.nl();
3900 convertStatementListCSharp(RestStatements, Level);
3901 return;
3902 }
3903 }
3904 {
3905 Variable RestStatements = new Variable();
3906 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
3907 {
3908 convertIndentationCSharp(Level);
3909 YP.write(Atom.a(@"return true;"));
3910 YP.nl();
3911 convertStatementListCSharp(RestStatements, Level);
3912 return;
3913 }
3914 }
3915 {
3916 Variable RestStatements = new Variable();
3917 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
3918 {
3919 convertIndentationCSharp(Level);
3920 YP.write(Atom.a(@"return false;"));
3921 YP.nl();
3922 convertStatementListCSharp(RestStatements, Level);
3923 return;
3924 }
3925 }
3926 {
3927 Variable Name = new Variable();
3928 Variable RestStatements = new Variable();
3929 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements)))
3930 {
3931 convertIndentationCSharp(Level);
3932 YP.write(Name);
3933 YP.write(Atom.a(@":"));
3934 YP.nl();
3935 if (YP.termEqual(RestStatements, Atom.NIL))
3936 {
3937 convertIndentationCSharp(Level);
3938 YP.write(Atom.a(@"{}"));
3939 YP.nl();
3940 convertStatementListCSharp(RestStatements, Level);
3941 return;
3942 goto cutIf1;
3943 }
3944 convertStatementListCSharp(RestStatements, Level);
3945 return;
3946 cutIf1:
3947 { }
3948 }
3949 }
3950 {
3951 Variable Name = new Variable();
3952 Variable RestStatements = new Variable();
3953 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
3954 {
3955 convertIndentationCSharp(Level);
3956 YP.write(Atom.a(@"goto "));
3957 YP.write(Name);
3958 YP.write(Atom.a(@";"));
3959 YP.nl();
3960 convertStatementListCSharp(RestStatements, Level);
3961 return;
3962 }
3963 }
3964 {
3965 Variable Name = new Variable();
3966 Variable ArgList = new Variable();
3967 Variable RestStatements = new Variable();
3968 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
3969 {
3970 convertIndentationCSharp(Level);
3971 YP.write(Name);
3972 YP.write(Atom.a(@"("));
3973 convertArgListCSharp(ArgList);
3974 YP.write(Atom.a(@");"));
3975 YP.nl();
3976 convertStatementListCSharp(RestStatements, Level);
3977 return;
3978 }
3979 }
3980 {
3981 Variable Obj = new Variable();
3982 Variable Name = new Variable();
3983 Variable ArgList = new Variable();
3984 Variable RestStatements = new Variable();
3985 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
3986 {
3987 convertIndentationCSharp(Level);
3988 YP.write(Obj);
3989 YP.write(Atom.a(@"."));
3990 YP.write(Name);
3991 YP.write(Atom.a(@"("));
3992 convertArgListCSharp(ArgList);
3993 YP.write(Atom.a(@");"));
3994 YP.nl();
3995 convertStatementListCSharp(RestStatements, Level);
3996 return;
3997 }
3998 }
3999 {
4000 Variable Body = new Variable();
4001 Variable RestStatements = new Variable();
4002 Variable NextLevel = new Variable();
4003 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4004 {
4005 convertIndentationCSharp(Level);
4006 YP.write(Atom.a(@"{"));
4007 YP.nl();
4008 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4009 {
4010 convertStatementListCSharp(Body, NextLevel);
4011 convertIndentationCSharp(Level);
4012 YP.write(Atom.a(@"}"));
4013 YP.nl();
4014 convertStatementListCSharp(RestStatements, Level);
4015 return;
4016 }
4017 }
4018 }
4019 {
4020 Variable Expression = new Variable();
4021 Variable Body = new Variable();
4022 Variable RestStatements = new Variable();
4023 Variable NextLevel = new Variable();
4024 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4025 {
4026 convertIndentationCSharp(Level);
4027 YP.write(Atom.a(@"if ("));
4028 convertExpressionCSharp(Expression);
4029 YP.write(Atom.a(@") {"));
4030 YP.nl();
4031 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4032 {
4033 convertStatementListCSharp(Body, NextLevel);
4034 convertIndentationCSharp(Level);
4035 YP.write(Atom.a(@"}"));
4036 YP.nl();
4037 convertStatementListCSharp(RestStatements, Level);
4038 return;
4039 }
4040 }
4041 }
4042 {
4043 Variable Expression = new Variable();
4044 Variable Body = new Variable();
4045 Variable RestStatements = new Variable();
4046 Variable NextLevel = new Variable();
4047 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4048 {
4049 convertIndentationCSharp(Level);
4050 YP.write(Atom.a(@"foreach (bool l"));
4051 YP.write(Level);
4052 YP.write(Atom.a(@" in "));
4053 convertExpressionCSharp(Expression);
4054 YP.write(Atom.a(@") {"));
4055 YP.nl();
4056 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4057 {
4058 convertStatementListCSharp(Body, NextLevel);
4059 convertIndentationCSharp(Level);
4060 YP.write(Atom.a(@"}"));
4061 YP.nl();
4062 convertStatementListCSharp(RestStatements, Level);
4063 return;
4064 }
4065 }
4066 }
4067 {
4068 Variable Expression = new Variable();
4069 Variable RestStatements = new Variable();
4070 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
4071 {
4072 convertIndentationCSharp(Level);
4073 YP.write(Atom.a(@"throw "));
4074 convertExpressionCSharp(Expression);
4075 YP.write(Atom.a(@";"));
4076 YP.nl();
4077 convertStatementListCSharp(RestStatements, Level);
4078 return;
4079 }
4080 }
4081 }
4082
4083 public static void convertIndentationCSharp(object Level)
4084 {
4085 {
4086 Variable N = new Variable();
4087 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4088 {
4089 repeatWrite(Atom.a(@" "), N);
4090 return;
4091 }
4092 }
4093 }
4094
4095 public static void convertArgListCSharp(object arg1)
4096 {
4097 {
4098 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4099 {
4100 return;
4101 }
4102 }
4103 {
4104 Variable Head = new Variable();
4105 Variable Tail = new Variable();
4106 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4107 {
4108 convertExpressionCSharp(Head);
4109 if (YP.termNotEqual(Tail, Atom.NIL))
4110 {
4111 YP.write(Atom.a(@", "));
4112 convertArgListCSharp(Tail);
4113 return;
4114 goto cutIf1;
4115 }
4116 convertArgListCSharp(Tail);
4117 return;
4118 cutIf1:
4119 { }
4120 }
4121 }
4122 }
4123
4124 public static void convertExpressionCSharp(object arg1)
4125 {
4126 {
4127 Variable X = new Variable();
4128 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4129 {
4130 YP.write(Atom.a(@"object "));
4131 YP.write(X);
4132 return;
4133 }
4134 }
4135 {
4136 Variable Name = new Variable();
4137 Variable ArgList = new Variable();
4138 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4139 {
4140 YP.write(Name);
4141 YP.write(Atom.a(@"("));
4142 convertArgListCSharp(ArgList);
4143 YP.write(Atom.a(@")"));
4144 return;
4145 }
4146 }
4147 {
4148 Variable Obj = new Variable();
4149 Variable Name = new Variable();
4150 Variable ArgList = new Variable();
4151 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4152 {
4153 YP.write(Obj);
4154 YP.write(Atom.a(@"."));
4155 YP.write(Name);
4156 YP.write(Atom.a(@"("));
4157 convertArgListCSharp(ArgList);
4158 YP.write(Atom.a(@")"));
4159 return;
4160 }
4161 }
4162 {
4163 Variable Name = new Variable();
4164 Variable ArgList = new Variable();
4165 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4166 {
4167 YP.write(Atom.a(@"new "));
4168 YP.write(Name);
4169 YP.write(Atom.a(@"("));
4170 convertArgListCSharp(ArgList);
4171 YP.write(Atom.a(@")"));
4172 return;
4173 }
4174 }
4175 {
4176 Variable Name = new Variable();
4177 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4178 {
4179 YP.write(Name);
4180 return;
4181 }
4182 }
4183 {
4184 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4185 {
4186 YP.write(Atom.a(@"null"));
4187 return;
4188 }
4189 }
4190 {
4191 Variable X = new Variable();
4192 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4193 {
4194 YP.write(Atom.a(@"!("));
4195 convertExpressionCSharp(X);
4196 YP.write(Atom.a(@")"));
4197 return;
4198 }
4199 }
4200 {
4201 Variable X = new Variable();
4202 Variable Y = new Variable();
4203 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4204 {
4205 YP.write(Atom.a(@"("));
4206 convertExpressionCSharp(X);
4207 YP.write(Atom.a(@") && ("));
4208 convertExpressionCSharp(Y);
4209 YP.write(Atom.a(@")"));
4210 return;
4211 }
4212 }
4213 {
4214 Variable ArgList = new Variable();
4215 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4216 {
4217 YP.write(Atom.a(@"new object[] {"));
4218 convertArgListCSharp(ArgList);
4219 YP.write(Atom.a(@"}"));
4220 return;
4221 }
4222 }
4223 {
4224 Variable X = new Variable();
4225 Variable Codes = new Variable();
4226 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4227 {
4228 if (YP.atom(X))
4229 {
4230 YP.write(Atom.a(@"@"""));
4231 foreach (bool l4 in YP.atom_codes(X, Codes))
4232 {
4233 convertStringCodesCSharp(Codes);
4234 YP.write(Atom.a(@""""));
4235 return;
4236 }
4237 }
4238 }
4239 }
4240 {
4241 Variable X = new Variable();
4242 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4243 {
4244 YP.write(X);
4245 return;
4246 }
4247 }
4248 }
4249
4250 public static void convertStringCodesCSharp(object arg1)
4251 {
4252 {
4253 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4254 {
4255 return;
4256 }
4257 }
4258 {
4259 Variable Code = new Variable();
4260 Variable RestCodes = new Variable();
4261 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4262 {
4263 if (YP.termEqual(Code, 34))
4264 {
4265 YP.put_code(34);
4266 YP.put_code(Code);
4267 convertStringCodesCSharp(RestCodes);
4268 return;
4269 goto cutIf1;
4270 }
4271 YP.put_code(Code);
4272 convertStringCodesCSharp(RestCodes);
4273 return;
4274 cutIf1:
4275 { }
4276 }
4277 }
4278 }
4279
4280 public static void convertFunctionJavascript(object arg1)
4281 {
4282 {
4283 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4284 {
4285 YP.write(Atom.a(@"function getDeclaringClass() { return null; }"));
4286 YP.nl();
4287 return;
4288 }
4289 }
4290 {
4291 Variable x1 = new Variable();
4292 Variable Name = new Variable();
4293 Variable ArgList = new Variable();
4294 Variable Body = new Variable();
4295 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4296 {
4297 YP.write(Atom.a(@"function "));
4298 YP.write(Name);
4299 YP.write(Atom.a(@"("));
4300 convertArgListJavascript(ArgList);
4301 YP.write(Atom.a(@") {"));
4302 YP.nl();
4303 convertStatementListJavascript(Body, 1);
4304 YP.write(Atom.a(@"}"));
4305 YP.nl();
4306 YP.nl();
4307 return;
4308 }
4309 }
4310 }
4311
4312 public static void convertStatementListJavascript(object arg1, object arg2)
4313 {
4314 {
4315 object x1 = arg2;
4316 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4317 {
4318 return;
4319 }
4320 }
4321 {
4322 object Level = arg2;
4323 Variable Name = new Variable();
4324 Variable Body = new Variable();
4325 Variable RestStatements = new Variable();
4326 Variable NextLevel = new Variable();
4327 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4328 {
4329 convertIndentationJavascript(Level);
4330 YP.write(Name);
4331 YP.write(Atom.a(@":"));
4332 YP.nl();
4333 convertIndentationJavascript(Level);
4334 YP.write(Atom.a(@"{"));
4335 YP.nl();
4336 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4337 {
4338 convertStatementListJavascript(Body, NextLevel);
4339 convertIndentationJavascript(Level);
4340 YP.write(Atom.a(@"}"));
4341 YP.nl();
4342 convertStatementListJavascript(RestStatements, Level);
4343 return;
4344 }
4345 }
4346 }
4347 {
4348 object Level = arg2;
4349 Variable _Type = new Variable();
4350 Variable Name = new Variable();
4351 Variable Expression = new Variable();
4352 Variable RestStatements = new Variable();
4353 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
4354 {
4355 convertIndentationJavascript(Level);
4356 YP.write(Atom.a(@"var "));
4357 YP.write(Name);
4358 YP.write(Atom.a(@" = "));
4359 convertExpressionJavascript(Expression);
4360 YP.write(Atom.a(@";"));
4361 YP.nl();
4362 convertStatementListJavascript(RestStatements, Level);
4363 return;
4364 }
4365 }
4366 {
4367 object Level = arg2;
4368 Variable Name = new Variable();
4369 Variable Expression = new Variable();
4370 Variable RestStatements = new Variable();
4371 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
4372 {
4373 convertIndentationJavascript(Level);
4374 YP.write(Name);
4375 YP.write(Atom.a(@" = "));
4376 convertExpressionJavascript(Expression);
4377 YP.write(Atom.a(@";"));
4378 YP.nl();
4379 convertStatementListJavascript(RestStatements, Level);
4380 return;
4381 }
4382 }
4383 {
4384 object Level = arg2;
4385 Variable RestStatements = new Variable();
4386 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
4387 {
4388 convertIndentationJavascript(Level);
4389 YP.write(Atom.a(@"yield true;"));
4390 YP.nl();
4391 convertStatementListJavascript(RestStatements, Level);
4392 return;
4393 }
4394 }
4395 {
4396 object Level = arg2;
4397 Variable RestStatements = new Variable();
4398 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
4399 {
4400 convertIndentationJavascript(Level);
4401 YP.write(Atom.a(@"yield false;"));
4402 YP.nl();
4403 convertStatementListJavascript(RestStatements, Level);
4404 return;
4405 }
4406 }
4407 {
4408 object Level = arg2;
4409 Variable RestStatements = new Variable();
4410 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
4411 {
4412 convertIndentationJavascript(Level);
4413 YP.write(Atom.a(@"return;"));
4414 YP.nl();
4415 convertStatementListJavascript(RestStatements, Level);
4416 return;
4417 }
4418 }
4419 {
4420 object Level = arg2;
4421 Variable RestStatements = new Variable();
4422 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
4423 {
4424 convertIndentationJavascript(Level);
4425 YP.write(Atom.a(@"return;"));
4426 YP.nl();
4427 convertStatementListJavascript(RestStatements, Level);
4428 return;
4429 }
4430 }
4431 {
4432 object Level = arg2;
4433 Variable RestStatements = new Variable();
4434 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
4435 {
4436 convertIndentationJavascript(Level);
4437 YP.write(Atom.a(@"return true;"));
4438 YP.nl();
4439 convertStatementListJavascript(RestStatements, Level);
4440 return;
4441 }
4442 }
4443 {
4444 object Level = arg2;
4445 Variable RestStatements = new Variable();
4446 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
4447 {
4448 convertIndentationJavascript(Level);
4449 YP.write(Atom.a(@"return false;"));
4450 YP.nl();
4451 convertStatementListJavascript(RestStatements, Level);
4452 return;
4453 }
4454 }
4455 {
4456 object Level = arg2;
4457 Variable Name = new Variable();
4458 Variable RestStatements = new Variable();
4459 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
4460 {
4461 convertIndentationJavascript(Level);
4462 YP.write(Atom.a(@"break "));
4463 YP.write(Name);
4464 YP.write(Atom.a(@";"));
4465 YP.nl();
4466 convertStatementListJavascript(RestStatements, Level);
4467 return;
4468 }
4469 }
4470 {
4471 object Level = arg2;
4472 Variable Name = new Variable();
4473 Variable ArgList = new Variable();
4474 Variable RestStatements = new Variable();
4475 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
4476 {
4477 convertIndentationJavascript(Level);
4478 YP.write(Name);
4479 YP.write(Atom.a(@"("));
4480 convertArgListJavascript(ArgList);
4481 YP.write(Atom.a(@");"));
4482 YP.nl();
4483 convertStatementListJavascript(RestStatements, Level);
4484 return;
4485 }
4486 }
4487 {
4488 object Level = arg2;
4489 Variable Obj = new Variable();
4490 Variable Name = new Variable();
4491 Variable ArgList = new Variable();
4492 Variable RestStatements = new Variable();
4493 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
4494 {
4495 convertIndentationJavascript(Level);
4496 YP.write(Obj);
4497 YP.write(Atom.a(@"."));
4498 YP.write(Name);
4499 YP.write(Atom.a(@"("));
4500 convertArgListJavascript(ArgList);
4501 YP.write(Atom.a(@");"));
4502 YP.nl();
4503 convertStatementListJavascript(RestStatements, Level);
4504 return;
4505 }
4506 }
4507 {
4508 object Level = arg2;
4509 Variable Body = new Variable();
4510 Variable RestStatements = new Variable();
4511 Variable NextLevel = new Variable();
4512 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
4513 {
4514 convertIndentationJavascript(Level);
4515 YP.write(Atom.a(@"{"));
4516 YP.nl();
4517 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4518 {
4519 convertStatementListJavascript(Body, NextLevel);
4520 convertIndentationJavascript(Level);
4521 YP.write(Atom.a(@"}"));
4522 YP.nl();
4523 convertStatementListJavascript(RestStatements, Level);
4524 return;
4525 }
4526 }
4527 }
4528 {
4529 object Level = arg2;
4530 Variable Expression = new Variable();
4531 Variable Body = new Variable();
4532 Variable RestStatements = new Variable();
4533 Variable NextLevel = new Variable();
4534 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
4535 {
4536 convertIndentationJavascript(Level);
4537 YP.write(Atom.a(@"if ("));
4538 convertExpressionJavascript(Expression);
4539 YP.write(Atom.a(@") {"));
4540 YP.nl();
4541 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4542 {
4543 convertStatementListJavascript(Body, NextLevel);
4544 convertIndentationJavascript(Level);
4545 YP.write(Atom.a(@"}"));
4546 YP.nl();
4547 convertStatementListJavascript(RestStatements, Level);
4548 return;
4549 }
4550 }
4551 }
4552 {
4553 object Level = arg2;
4554 Variable Expression = new Variable();
4555 Variable Body = new Variable();
4556 Variable RestStatements = new Variable();
4557 Variable NextLevel = new Variable();
4558 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
4559 {
4560 convertIndentationJavascript(Level);
4561 YP.write(Atom.a(@"for each (var l"));
4562 YP.write(Level);
4563 YP.write(Atom.a(@" in "));
4564 convertExpressionJavascript(Expression);
4565 YP.write(Atom.a(@") {"));
4566 YP.nl();
4567 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4568 {
4569 convertStatementListJavascript(Body, NextLevel);
4570 convertIndentationJavascript(Level);
4571 YP.write(Atom.a(@"}"));
4572 YP.nl();
4573 convertStatementListJavascript(RestStatements, Level);
4574 return;
4575 }
4576 }
4577 }
4578 {
4579 object Level = arg2;
4580 Variable Expression = new Variable();
4581 Variable RestStatements = new Variable();
4582 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
4583 {
4584 convertIndentationJavascript(Level);
4585 YP.write(Atom.a(@"throw "));
4586 convertExpressionJavascript(Expression);
4587 YP.write(Atom.a(@";"));
4588 YP.nl();
4589 convertStatementListJavascript(RestStatements, Level);
4590 return;
4591 }
4592 }
4593 }
4594
4595 public static void convertIndentationJavascript(object Level)
4596 {
4597 {
4598 Variable N = new Variable();
4599 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
4600 {
4601 repeatWrite(Atom.a(@" "), N);
4602 return;
4603 }
4604 }
4605 }
4606
4607 public static void convertArgListJavascript(object arg1)
4608 {
4609 {
4610 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4611 {
4612 return;
4613 }
4614 }
4615 {
4616 Variable Head = new Variable();
4617 Variable Tail = new Variable();
4618 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
4619 {
4620 convertExpressionJavascript(Head);
4621 if (YP.termNotEqual(Tail, Atom.NIL))
4622 {
4623 YP.write(Atom.a(@", "));
4624 convertArgListJavascript(Tail);
4625 return;
4626 goto cutIf1;
4627 }
4628 convertArgListJavascript(Tail);
4629 return;
4630 cutIf1:
4631 { }
4632 }
4633 }
4634 }
4635
4636 public static void convertExpressionJavascript(object arg1)
4637 {
4638 {
4639 Variable X = new Variable();
4640 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
4641 {
4642 YP.write(X);
4643 return;
4644 }
4645 }
4646 {
4647 Variable Name = new Variable();
4648 Variable ArgList = new Variable();
4649 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
4650 {
4651 YP.write(Name);
4652 YP.write(Atom.a(@"("));
4653 convertArgListJavascript(ArgList);
4654 YP.write(Atom.a(@")"));
4655 return;
4656 }
4657 }
4658 {
4659 Variable Obj = new Variable();
4660 Variable Name = new Variable();
4661 Variable ArgList = new Variable();
4662 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
4663 {
4664 YP.write(Obj);
4665 YP.write(Atom.a(@"."));
4666 YP.write(Name);
4667 YP.write(Atom.a(@"("));
4668 convertArgListJavascript(ArgList);
4669 YP.write(Atom.a(@")"));
4670 return;
4671 }
4672 }
4673 {
4674 Variable Name = new Variable();
4675 Variable ArgList = new Variable();
4676 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
4677 {
4678 YP.write(Atom.a(@"new "));
4679 YP.write(Name);
4680 YP.write(Atom.a(@"("));
4681 convertArgListJavascript(ArgList);
4682 YP.write(Atom.a(@")"));
4683 return;
4684 }
4685 }
4686 {
4687 Variable Name = new Variable();
4688 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
4689 {
4690 YP.write(Name);
4691 return;
4692 }
4693 }
4694 {
4695 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
4696 {
4697 YP.write(Atom.a(@"null"));
4698 return;
4699 }
4700 }
4701 {
4702 Variable X = new Variable();
4703 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
4704 {
4705 YP.write(Atom.a(@"!("));
4706 convertExpressionJavascript(X);
4707 YP.write(Atom.a(@")"));
4708 return;
4709 }
4710 }
4711 {
4712 Variable X = new Variable();
4713 Variable Y = new Variable();
4714 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
4715 {
4716 YP.write(Atom.a(@"("));
4717 convertExpressionJavascript(X);
4718 YP.write(Atom.a(@") && ("));
4719 convertExpressionJavascript(Y);
4720 YP.write(Atom.a(@")"));
4721 return;
4722 }
4723 }
4724 {
4725 Variable ArgList = new Variable();
4726 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
4727 {
4728 YP.write(Atom.a(@"["));
4729 convertArgListJavascript(ArgList);
4730 YP.write(Atom.a(@"]"));
4731 return;
4732 }
4733 }
4734 {
4735 Variable X = new Variable();
4736 Variable Codes = new Variable();
4737 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4738 {
4739 if (YP.atom(X))
4740 {
4741 YP.write(Atom.a(@""""));
4742 foreach (bool l4 in YP.atom_codes(X, Codes))
4743 {
4744 convertStringCodesJavascript(Codes);
4745 YP.write(Atom.a(@""""));
4746 return;
4747 }
4748 }
4749 }
4750 }
4751 {
4752 Variable X = new Variable();
4753 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
4754 {
4755 YP.write(X);
4756 return;
4757 }
4758 }
4759 }
4760
4761 public static void convertStringCodesJavascript(object arg1)
4762 {
4763 {
4764 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4765 {
4766 return;
4767 }
4768 }
4769 {
4770 Variable Code = new Variable();
4771 Variable RestCodes = new Variable();
4772 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
4773 {
4774 if (YP.termEqual(Code, 34))
4775 {
4776 YP.put_code(92);
4777 YP.put_code(Code);
4778 convertStringCodesJavascript(RestCodes);
4779 return;
4780 goto cutIf1;
4781 }
4782 if (YP.termEqual(Code, 92))
4783 {
4784 YP.put_code(92);
4785 YP.put_code(Code);
4786 convertStringCodesJavascript(RestCodes);
4787 return;
4788 goto cutIf1;
4789 }
4790 YP.put_code(Code);
4791 convertStringCodesJavascript(RestCodes);
4792 return;
4793 cutIf1:
4794 { }
4795 }
4796 }
4797 }
4798
4799 public static void convertFunctionPython(object arg1)
4800 {
4801 {
4802 foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
4803 {
4804 YP.write(Atom.a(@"def getDeclaringClass():"));
4805 YP.nl();
4806 YP.write(Atom.a(@" return None"));
4807 YP.nl();
4808 YP.nl();
4809 return;
4810 }
4811 }
4812 {
4813 Variable x1 = new Variable();
4814 Variable Name = new Variable();
4815 Variable ArgList = new Variable();
4816 Variable Body = new Variable();
4817 Variable Level = new Variable();
4818 Variable HasBreakableBlock = new Variable();
4819 foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
4820 {
4821 YP.write(Atom.a(@"def "));
4822 YP.write(Name);
4823 YP.write(Atom.a(@"("));
4824 convertArgListPython(ArgList);
4825 YP.write(Atom.a(@"):"));
4826 YP.nl();
4827 foreach (bool l3 in YP.unify(Level, 1))
4828 {
4829 if (hasBreakableBlockPython(Body))
4830 {
4831 foreach (bool l5 in YP.unify(HasBreakableBlock, 1))
4832 {
4833 if (YP.termEqual(HasBreakableBlock, 1))
4834 {
4835 convertIndentationPython(Level);
4836 YP.write(Atom.a(@"doBreak = False"));
4837 YP.nl();
4838 foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
4839 {
4840 YP.nl();
4841 return;
4842 }
4843 goto cutIf2;
4844 }
4845 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4846 {
4847 YP.nl();
4848 return;
4849 }
4850 cutIf2:
4851 { }
4852 }
4853 goto cutIf1;
4854 }
4855 foreach (bool l4 in YP.unify(HasBreakableBlock, 0))
4856 {
4857 if (YP.termEqual(HasBreakableBlock, 1))
4858 {
4859 convertIndentationPython(Level);
4860 YP.write(Atom.a(@"doBreak = False"));
4861 YP.nl();
4862 foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
4863 {
4864 YP.nl();
4865 return;
4866 }
4867 goto cutIf3;
4868 }
4869 foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock))
4870 {
4871 YP.nl();
4872 return;
4873 }
4874 cutIf3:
4875 { }
4876 }
4877 cutIf1:
4878 { }
4879 }
4880 }
4881 }
4882 }
4883
4884 public static bool hasBreakableBlockPython(object arg1)
4885 {
4886 {
4887 Variable _Name = new Variable();
4888 Variable _Body = new Variable();
4889 Variable _RestStatements = new Variable();
4890 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements)))
4891 {
4892 return true;
4893 }
4894 }
4895 {
4896 Variable Body = new Variable();
4897 Variable _RestStatements = new Variable();
4898 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements)))
4899 {
4900 if (hasBreakableBlockPython(Body))
4901 {
4902 return true;
4903 }
4904 }
4905 }
4906 {
4907 Variable _Expression = new Variable();
4908 Variable Body = new Variable();
4909 Variable _RestStatements = new Variable();
4910 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements)))
4911 {
4912 if (hasBreakableBlockPython(Body))
4913 {
4914 return true;
4915 }
4916 }
4917 }
4918 {
4919 Variable _Expression = new Variable();
4920 Variable Body = new Variable();
4921 Variable _RestStatements = new Variable();
4922 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements)))
4923 {
4924 if (hasBreakableBlockPython(Body))
4925 {
4926 return true;
4927 }
4928 }
4929 }
4930 {
4931 Variable x1 = new Variable();
4932 Variable RestStatements = new Variable();
4933 foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements)))
4934 {
4935 if (hasBreakableBlockPython(RestStatements))
4936 {
4937 return true;
4938 }
4939 }
4940 }
4941 return false;
4942 }
4943
4944 public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3)
4945 {
4946 {
4947 object x1 = arg2;
4948 object x2 = arg3;
4949 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
4950 {
4951 yield return true;
4952 yield break;
4953 }
4954 }
4955 {
4956 object Level = arg2;
4957 object HasBreakableBlock = arg3;
4958 Variable Name = new Variable();
4959 Variable Body = new Variable();
4960 Variable RestStatements = new Variable();
4961 Variable NextLevel = new Variable();
4962 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
4963 {
4964 convertIndentationPython(Level);
4965 YP.write(Name);
4966 YP.write(Atom.a(@" = False"));
4967 YP.nl();
4968 convertIndentationPython(Level);
4969 YP.write(Atom.a(@"for _ in [1]:"));
4970 YP.nl();
4971 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
4972 {
4973 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
4974 {
4975 convertIndentationPython(Level);
4976 YP.write(Atom.a(@"if "));
4977 YP.write(Name);
4978 YP.write(Atom.a(@":"));
4979 YP.nl();
4980 convertIndentationPython(NextLevel);
4981 YP.write(Atom.a(@"doBreak = False"));
4982 YP.nl();
4983 convertIndentationPython(Level);
4984 YP.write(Atom.a(@"if doBreak:"));
4985 YP.nl();
4986 convertIndentationPython(NextLevel);
4987 YP.write(Atom.a(@"break"));
4988 YP.nl();
4989 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
4990 {
4991 yield return true;
4992 yield break;
4993 }
4994 }
4995 }
4996 }
4997 }
4998 {
4999 object Level = arg2;
5000 object HasBreakableBlock = arg3;
5001 Variable _Type = new Variable();
5002 Variable Name = new Variable();
5003 Variable Expression = new Variable();
5004 Variable RestStatements = new Variable();
5005 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
5006 {
5007 convertIndentationPython(Level);
5008 YP.write(Name);
5009 YP.write(Atom.a(@" = "));
5010 convertExpressionPython(Expression);
5011 YP.nl();
5012 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5013 {
5014 yield return true;
5015 yield break;
5016 }
5017 }
5018 }
5019 {
5020 object Level = arg2;
5021 object HasBreakableBlock = arg3;
5022 Variable Name = new Variable();
5023 Variable Expression = new Variable();
5024 Variable RestStatements = new Variable();
5025 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
5026 {
5027 convertIndentationPython(Level);
5028 YP.write(Name);
5029 YP.write(Atom.a(@" = "));
5030 convertExpressionPython(Expression);
5031 YP.nl();
5032 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5033 {
5034 yield return true;
5035 yield break;
5036 }
5037 }
5038 }
5039 {
5040 object Level = arg2;
5041 object HasBreakableBlock = arg3;
5042 Variable RestStatements = new Variable();
5043 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
5044 {
5045 convertIndentationPython(Level);
5046 YP.write(Atom.a(@"yield True"));
5047 YP.nl();
5048 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5049 {
5050 yield return true;
5051 yield break;
5052 }
5053 }
5054 }
5055 {
5056 object Level = arg2;
5057 object HasBreakableBlock = arg3;
5058 Variable RestStatements = new Variable();
5059 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
5060 {
5061 convertIndentationPython(Level);
5062 YP.write(Atom.a(@"yield False"));
5063 YP.nl();
5064 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5065 {
5066 yield return true;
5067 yield break;
5068 }
5069 }
5070 }
5071 {
5072 object Level = arg2;
5073 object HasBreakableBlock = arg3;
5074 Variable RestStatements = new Variable();
5075 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
5076 {
5077 convertIndentationPython(Level);
5078 YP.write(Atom.a(@"return"));
5079 YP.nl();
5080 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5081 {
5082 yield return true;
5083 yield break;
5084 }
5085 }
5086 }
5087 {
5088 object Level = arg2;
5089 object HasBreakableBlock = arg3;
5090 Variable RestStatements = new Variable();
5091 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
5092 {
5093 convertIndentationPython(Level);
5094 YP.write(Atom.a(@"return"));
5095 YP.nl();
5096 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5097 {
5098 yield return true;
5099 yield break;
5100 }
5101 }
5102 }
5103 {
5104 object Level = arg2;
5105 object HasBreakableBlock = arg3;
5106 Variable RestStatements = new Variable();
5107 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
5108 {
5109 convertIndentationPython(Level);
5110 YP.write(Atom.a(@"return True"));
5111 YP.nl();
5112 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5113 {
5114 yield return true;
5115 yield break;
5116 }
5117 }
5118 }
5119 {
5120 object Level = arg2;
5121 object HasBreakableBlock = arg3;
5122 Variable RestStatements = new Variable();
5123 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
5124 {
5125 convertIndentationPython(Level);
5126 YP.write(Atom.a(@"return False"));
5127 YP.nl();
5128 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5129 {
5130 yield return true;
5131 yield break;
5132 }
5133 }
5134 }
5135 {
5136 object Level = arg2;
5137 object HasBreakableBlock = arg3;
5138 Variable Name = new Variable();
5139 Variable RestStatements = new Variable();
5140 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
5141 {
5142 convertIndentationPython(Level);
5143 YP.write(Name);
5144 YP.write(Atom.a(@" = True"));
5145 YP.nl();
5146 convertIndentationPython(Level);
5147 YP.write(Atom.a(@"doBreak = True"));
5148 YP.nl();
5149 convertIndentationPython(Level);
5150 YP.write(Atom.a(@"break"));
5151 YP.nl();
5152 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5153 {
5154 yield return true;
5155 yield break;
5156 }
5157 }
5158 }
5159 {
5160 object Level = arg2;
5161 object HasBreakableBlock = arg3;
5162 Variable Name = new Variable();
5163 Variable ArgList = new Variable();
5164 Variable RestStatements = new Variable();
5165 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
5166 {
5167 convertIndentationPython(Level);
5168 YP.write(Name);
5169 YP.write(Atom.a(@"("));
5170 convertArgListPython(ArgList);
5171 YP.write(Atom.a(@")"));
5172 YP.nl();
5173 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5174 {
5175 yield return true;
5176 yield break;
5177 }
5178 }
5179 }
5180 {
5181 object Level = arg2;
5182 object HasBreakableBlock = arg3;
5183 Variable Obj = new Variable();
5184 Variable Name = new Variable();
5185 Variable ArgList = new Variable();
5186 Variable RestStatements = new Variable();
5187 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
5188 {
5189 convertIndentationPython(Level);
5190 YP.write(Obj);
5191 YP.write(Atom.a(@"."));
5192 YP.write(Name);
5193 YP.write(Atom.a(@"("));
5194 convertArgListPython(ArgList);
5195 YP.write(Atom.a(@")"));
5196 YP.nl();
5197 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5198 {
5199 yield return true;
5200 yield break;
5201 }
5202 }
5203 }
5204 {
5205 object Level = arg2;
5206 object HasBreakableBlock = arg3;
5207 Variable Body = new Variable();
5208 Variable RestStatements = new Variable();
5209 Variable NextLevel = new Variable();
5210 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
5211 {
5212 if (YP.termEqual(HasBreakableBlock, 1))
5213 {
5214 convertIndentationPython(Level);
5215 YP.write(Atom.a(@"for _ in [1]:"));
5216 YP.nl();
5217 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
5218 {
5219 foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5220 {
5221 if (YP.termEqual(HasBreakableBlock, 1))
5222 {
5223 if (YP.greaterThan(Level, 1))
5224 {
5225 convertIndentationPython(Level);
5226 YP.write(Atom.a(@"if doBreak:"));
5227 YP.nl();
5228 convertIndentationPython(NextLevel);
5229 YP.write(Atom.a(@"break"));
5230 YP.nl();
5231 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5232 {
5233 yield return true;
5234 yield break;
5235 }
5236 goto cutIf3;
5237 }
5238 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5239 {
5240 yield return true;
5241 yield break;
5242 }
5243 cutIf3:
5244 goto cutIf2;
5245 }
5246 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5247 {
5248 yield return true;
5249 yield break;
5250 }
5251 cutIf2:
5252 { }
5253 }
5254 }
5255 goto cutIf1;
5256 }
5257 foreach (bool l3 in YP.unify(NextLevel, Level))
5258 {
5259 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5260 {
5261 if (YP.termEqual(HasBreakableBlock, 1))
5262 {
5263 if (YP.greaterThan(Level, 1))
5264 {
5265 convertIndentationPython(Level);
5266 YP.write(Atom.a(@"if doBreak:"));
5267 YP.nl();
5268 convertIndentationPython(NextLevel);
5269 YP.write(Atom.a(@"break"));
5270 YP.nl();
5271 foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5272 {
5273 yield return true;
5274 yield break;
5275 }
5276 goto cutIf5;
5277 }
5278 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5279 {
5280 yield return true;
5281 yield break;
5282 }
5283 cutIf5:
5284 goto cutIf4;
5285 }
5286 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5287 {
5288 yield return true;
5289 yield break;
5290 }
5291 cutIf4:
5292 { }
5293 }
5294 }
5295 cutIf1:
5296 { }
5297 }
5298 }
5299 {
5300 object Level = arg2;
5301 object HasBreakableBlock = arg3;
5302 Variable Expression = new Variable();
5303 Variable Body = new Variable();
5304 Variable RestStatements = new Variable();
5305 Variable NextLevel = new Variable();
5306 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
5307 {
5308 convertIndentationPython(Level);
5309 YP.write(Atom.a(@"if "));
5310 convertExpressionPython(Expression);
5311 YP.write(Atom.a(@":"));
5312 YP.nl();
5313 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5314 {
5315 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5316 {
5317 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5318 {
5319 yield return true;
5320 yield break;
5321 }
5322 }
5323 }
5324 }
5325 }
5326 {
5327 object Level = arg2;
5328 object HasBreakableBlock = arg3;
5329 Variable Expression = new Variable();
5330 Variable Body = new Variable();
5331 Variable RestStatements = new Variable();
5332 Variable NextLevel = new Variable();
5333 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
5334 {
5335 convertIndentationPython(Level);
5336 YP.write(Atom.a(@"for l"));
5337 YP.write(Level);
5338 YP.write(Atom.a(@" in "));
5339 convertExpressionPython(Expression);
5340 YP.write(Atom.a(@":"));
5341 YP.nl();
5342 foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
5343 {
5344 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
5345 {
5346 if (YP.termEqual(HasBreakableBlock, 1))
5347 {
5348 convertIndentationPython(Level);
5349 YP.write(Atom.a(@"if doBreak:"));
5350 YP.nl();
5351 convertIndentationPython(NextLevel);
5352 YP.write(Atom.a(@"break"));
5353 YP.nl();
5354 foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5355 {
5356 yield return true;
5357 yield break;
5358 }
5359 goto cutIf6;
5360 }
5361 foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5362 {
5363 yield return true;
5364 yield break;
5365 }
5366 cutIf6:
5367 { }
5368 }
5369 }
5370 }
5371 }
5372 {
5373 object Level = arg2;
5374 object HasBreakableBlock = arg3;
5375 Variable Expression = new Variable();
5376 Variable RestStatements = new Variable();
5377 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
5378 {
5379 convertIndentationPython(Level);
5380 YP.write(Atom.a(@"raise "));
5381 convertExpressionPython(Expression);
5382 YP.nl();
5383 foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
5384 {
5385 yield return true;
5386 yield break;
5387 }
5388 }
5389 }
5390 }
5391
5392 public static void convertIndentationPython(object Level)
5393 {
5394 {
5395 Variable N = new Variable();
5396 foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
5397 {
5398 repeatWrite(Atom.a(@" "), N);
5399 return;
5400 }
5401 }
5402 }
5403
5404 public static void convertArgListPython(object arg1)
5405 {
5406 {
5407 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5408 {
5409 return;
5410 }
5411 }
5412 {
5413 Variable Head = new Variable();
5414 Variable Tail = new Variable();
5415 foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
5416 {
5417 convertExpressionPython(Head);
5418 if (YP.termNotEqual(Tail, Atom.NIL))
5419 {
5420 YP.write(Atom.a(@", "));
5421 convertArgListPython(Tail);
5422 return;
5423 goto cutIf1;
5424 }
5425 convertArgListPython(Tail);
5426 return;
5427 cutIf1:
5428 { }
5429 }
5430 }
5431 }
5432
5433 public static void convertExpressionPython(object arg1)
5434 {
5435 {
5436 Variable X = new Variable();
5437 foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
5438 {
5439 YP.write(X);
5440 return;
5441 }
5442 }
5443 {
5444 Variable Name = new Variable();
5445 Variable ArgList = new Variable();
5446 foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
5447 {
5448 YP.write(Name);
5449 YP.write(Atom.a(@"("));
5450 convertArgListPython(ArgList);
5451 YP.write(Atom.a(@")"));
5452 return;
5453 }
5454 }
5455 {
5456 Variable Obj = new Variable();
5457 Variable Name = new Variable();
5458 Variable ArgList = new Variable();
5459 foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
5460 {
5461 YP.write(Obj);
5462 YP.write(Atom.a(@"."));
5463 YP.write(Name);
5464 YP.write(Atom.a(@"("));
5465 convertArgListPython(ArgList);
5466 YP.write(Atom.a(@")"));
5467 return;
5468 }
5469 }
5470 {
5471 Variable Name = new Variable();
5472 Variable ArgList = new Variable();
5473 foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
5474 {
5475 YP.write(Name);
5476 YP.write(Atom.a(@"("));
5477 convertArgListPython(ArgList);
5478 YP.write(Atom.a(@")"));
5479 return;
5480 }
5481 }
5482 {
5483 Variable Name = new Variable();
5484 foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
5485 {
5486 YP.write(Name);
5487 return;
5488 }
5489 }
5490 {
5491 foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
5492 {
5493 YP.write(Atom.a(@"None"));
5494 return;
5495 }
5496 }
5497 {
5498 Variable X = new Variable();
5499 foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
5500 {
5501 YP.write(Atom.a(@"not ("));
5502 convertExpressionPython(X);
5503 YP.write(Atom.a(@")"));
5504 return;
5505 }
5506 }
5507 {
5508 Variable X = new Variable();
5509 Variable Y = new Variable();
5510 foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
5511 {
5512 YP.write(Atom.a(@"("));
5513 convertExpressionPython(X);
5514 YP.write(Atom.a(@") and ("));
5515 convertExpressionPython(Y);
5516 YP.write(Atom.a(@")"));
5517 return;
5518 }
5519 }
5520 {
5521 Variable ArgList = new Variable();
5522 foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
5523 {
5524 YP.write(Atom.a(@"["));
5525 convertArgListPython(ArgList);
5526 YP.write(Atom.a(@"]"));
5527 return;
5528 }
5529 }
5530 {
5531 Variable X = new Variable();
5532 Variable Codes = new Variable();
5533 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5534 {
5535 if (YP.atom(X))
5536 {
5537 YP.write(Atom.a(@""""));
5538 foreach (bool l4 in YP.atom_codes(X, Codes))
5539 {
5540 convertStringCodesPython(Codes);
5541 YP.write(Atom.a(@""""));
5542 return;
5543 }
5544 }
5545 }
5546 }
5547 {
5548 Variable X = new Variable();
5549 foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
5550 {
5551 YP.write(X);
5552 return;
5553 }
5554 }
5555 }
5556
5557 public static void convertStringCodesPython(object arg1)
5558 {
5559 {
5560 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5561 {
5562 return;
5563 }
5564 }
5565 {
5566 Variable Code = new Variable();
5567 Variable RestCodes = new Variable();
5568 foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
5569 {
5570 if (YP.termEqual(Code, 34))
5571 {
5572 YP.put_code(92);
5573 YP.put_code(Code);
5574 convertStringCodesPython(RestCodes);
5575 return;
5576 goto cutIf1;
5577 }
5578 if (YP.termEqual(Code, 92))
5579 {
5580 YP.put_code(92);
5581 YP.put_code(Code);
5582 convertStringCodesPython(RestCodes);
5583 return;
5584 goto cutIf1;
5585 }
5586 YP.put_code(Code);
5587 convertStringCodesPython(RestCodes);
5588 return;
5589 cutIf1:
5590 { }
5591 }
5592 }
5593 }
5594
5595 public static IEnumerable<bool> member(object X, object arg2)
5596 {
5597 {
5598 Variable x2 = new Variable();
5599 foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2)))
5600 {
5601 yield return false;
5602 }
5603 }
5604 {
5605 Variable x2 = new Variable();
5606 Variable Rest = new Variable();
5607 foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest)))
5608 {
5609 foreach (bool l3 in member(X, Rest))
5610 {
5611 yield return false;
5612 }
5613 }
5614 }
5615 }
5616
5617 public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
5618 {
5619 {
5620 Variable List = new Variable();
5621 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
5622 {
5623 foreach (bool l3 in YP.unify(arg2, List))
5624 {
5625 foreach (bool l4 in YP.unify(arg3, List))
5626 {
5627 yield return false;
5628 }
5629 }
5630 }
5631 }
5632 {
5633 object List2 = arg2;
5634 Variable X = new Variable();
5635 Variable List1 = new Variable();
5636 Variable List12 = new Variable();
5637 foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
5638 {
5639 foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
5640 {
5641 foreach (bool l4 in append(List1, List2, List12))
5642 {
5643 yield return false;
5644 }
5645 }
5646 }
5647 }
5648 }
5649
5650 }
5651}