Adding a new builtin function

new topic     » topic index » view thread      » older message » newer message

I started grepping through the source code today in an attempt to add a new builtin function. For example, I want to add a simple function that takes 1 input (atom) and returns 1 output (atom): atom foo(atom a). I found some tips/instructions in the source files, but I'm missing some key steps. In reswors.h it says:

  remember to update reswords.e, opnames.e, 
   opnames.h, optable[], localjumptab[] 
   in be_execute.c, be_runtime.c. redef.h, 
   emit.e, keylist.e, compile.e, be_syncolor.c 

I've taken a stab at editing these files with a new reserved word 'foo' and using the builtin 'cos' function as an example. I gave my function a new opcode and added entries to the files listed above. After rebuilding euphoria, I get the following when trying to use 'foo' in code:

Fatal run-time error: 
BAD IL OPCODE: i is 4, word is 1590060 (max=12), len is 1076948992 

The error occurs in the function code_set_pointers in be_execute.c. Any suggestions?

Thanks,
Ira

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu