Skip to content

Commit

Permalink
Concurrency (#38)
Browse files Browse the repository at this point in the history
* Add support for randomised context switching

* Remove unused import

* Attempt to support go statements

* Support for functions with multiple return values (#31) (#34)

* Implement fmt.Print()

* Update tests for println and print and implement trivial case for printf

* Fix array newline not ignored between { and first element

* Support for functions returning multiple values at once

* Remove duplicate test cases

* Improve concurrency handling to pass by value but random execution still does not work

* Implement mutex

* Fix defer not working inside non-main contexts

* Add more test cases for mutex

* Add method checking test case for mutex

* Fix defer and clean up duplicate files

* Remove debugging variables

* Add test cases for parsing for if-else statements

* Transfer test case from defer to go statement

* Support other numeric types and fix go statement remnant closure on OS

* Fix local browser testing error

* Remove redundant functions and refactor fork to go

* Fix multiple return values logic and added more test cases

* Adjust logic for handling functions that return multiple values

* Implement single level type declaration

* Improve basic test cases for type declaration

* Update logic to no longer use DeclaredNode

* Refactor executor to runtime, compiler to executor, parser to compiler

* Adjust logic for declared types to make literals commit to declared types instead of the other way round

* Implement declared type logic check for binops

* Fix uninitialised declared type variables not having zero values

* Implement type declarations for functions

* Implement type declaration and functions with multiple return values for arrays

* Implement support for same name type across different scopes

* fix whitespace removal logic for structs

* Change memory layout for arrays to be contiguous

* Remove dummy variables

* Change memory layout for arrays to be contiguous, however does not work without explicit size declaration

* Fix slices and structs
  • Loading branch information
chengda300 authored Feb 20, 2025
1 parent c7ae815 commit 9deb6cf
Show file tree
Hide file tree
Showing 106 changed files with 4,467 additions and 2,421 deletions.
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\src\\index.tsx",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"eject": "react-scripts eject",
"lint-no-fix": "eslint ./ --ignore-path .gitignore && prettier . -c",
"lint": "eslint ./ --ignore-path .gitignore --fix && prettier . -c --write",
"generate-parser": "npx peggy --format es -o src/go-virtual-machine-main/virtual-machine/parser/golang_parser.js src/go-virtual-machine-main/virtual-machine/parser/parser.peggy",
"generate-parser-watch": "npx peggy -m -w --format es -o src/go-virtual-machine-main/virtual-machine/parser/golang_parser.js src/go-virtual-machine-main/virtual-machine/parser/parser.peggy"
"generate-parser": "npx peggy --format es -o src/go-virtual-machine-main/virtual-machine/compiler/golang_parser.js src/go-virtual-machine-main/virtual-machine/compiler/parser.peggy",
"generate-parser-watch": "npx peggy -m -w --format es -o src/go-virtual-machine-main/virtual-machine/compiler/golang_parser.js src/go-virtual-machine-main/virtual-machine/compiler/parser.peggy"
},
"author": "",
"license": "ISC",
Expand All @@ -35,7 +35,7 @@
"framer-motion": "^10.12.14",
"js-cookie": "^3.0.5",
"node": "^22.7.0",
"peggy": "^4.0.3",
"peggy": "^4.1.1",
"react": "^18.2.0",
"react-cytoscapejs": "^2.0.0",
"react-data-grid": "^7.0.0-beta.34",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/Visual/EnvNode.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Edge, Handle, MarkerType, Node, NodeProps, Position } from 'reactflow'
import { Box } from '@chakra-ui/react'

import { EnvironmentInfo } from '../../../virtual-machine/executor/debugger'
import { EnvironmentInfo } from '../../../go-virtual-machine-main/virtual-machine/runtime/debugger'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Nodes = Node<any, string | undefined>[]
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/Visual/VisualArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
useColorModeValue,
} from '@chakra-ui/react'

import { ContextInfo } from '../../../virtual-machine/executor/debugger'
import { ContextInfo } from '../../../go-virtual-machine-main/virtual-machine/runtime/debugger'
import { useExecutionStore } from '../../stores'

import { addEnvs, EnvNode, Nodes } from './EnvNode'
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/pages/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
} from '@chakra-ui/react'
import Cookies from 'js-cookie'

import { runCode } from '../../virtual-machine'
import { CompileError } from '../../virtual-machine/compiler'
import { runCode } from '../../go-virtual-machine-main/tests/utility'
import { CompileError } from '../../go-virtual-machine-main/virtual-machine/executor/index'
import {
CodeIDE,
CodeIDEButtons,
Expand Down Expand Up @@ -145,7 +145,7 @@ export const Main = () => {
error,
output: newOutput,
visualData,
} = runCode(code, heapsize, visualMode)
} = runCode(code, heapsize, true, visualMode)
if (error) {
const errorTitle = {
parse: 'Syntax Error',
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/stores/executionStore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { shallow } from 'zustand/shallow'
import { createWithEqualityFn } from 'zustand/traditional'

import { ContextInfo, StateInfo } from '../../virtual-machine/executor/debugger'
import { TokenLocation } from '../../virtual-machine/parser/tokens'
import { ContextInfo, StateInfo } from '../../go-virtual-machine-main/virtual-machine/runtime/debugger'
import { TokenLocation } from '../../go-virtual-machine-main/virtual-machine/compiler/tokens'

export interface ExecutionState {
currentStep: number
Expand Down
3 changes: 0 additions & 3 deletions src/go-virtual-machine-main/.vscode/extensions.json

This file was deleted.

3 changes: 0 additions & 3 deletions src/go-virtual-machine-main/.vscode/settings.json

This file was deleted.

15 changes: 0 additions & 15 deletions src/go-virtual-machine-main/frontend/app/App.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/go-virtual-machine-main/frontend/app/Router.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/go-virtual-machine-main/frontend/app/index.ts

This file was deleted.

123 changes: 0 additions & 123 deletions src/go-virtual-machine-main/frontend/components/CodeIDE/CodeIDE.tsx

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9deb6cf

Please sign in to comment.