Skip to content

Commit

Permalink
feat: iteratable strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pacifiquem committed Mar 3, 2024
1 parent 51bc6a7 commit 750e7e3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/runtime/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from 'fs';
import path from 'path';
import { Runtime } from 'inspector';
import { NumericLiteral } from '../parser/ast';

export function createGlobalEnv(filename: string): Environment {
const env = new Environment();
Expand Down Expand Up @@ -169,6 +170,14 @@ export function createGlobalEnv(filename: string): Environment {
return MK_NUMBER(str.length);
}),
)
.set(
'inyuguti',
MK_NATIVE_FN((args, env) => {
const str = (args[0] as StringVal).value;
const charIndex = (args[1] as NumberVal).value;
return MK_STRING(str.charAt(charIndex));
}),
)
.set(
'inyuguti_nkuru',
MK_NATIVE_FN((args, env) => {
Expand Down

0 comments on commit 750e7e3

Please sign in to comment.