Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json parser #23

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
495c2b1
[WIP] Move to C
jrchatruc Jul 12, 2023
15a8f13
Check failing tests in CI
jrchatruc Jul 12, 2023
3b4b383
Revert "Check failing tests in CI"
jrchatruc Jul 12, 2023
dcc9a03
Test failing format in CI
jrchatruc Jul 12, 2023
bcea8ae
make fmt
jrchatruc Jul 12, 2023
3770742
Some progress
jrchatruc Jul 12, 2023
8756ab4
Add address sanitizer
jrchatruc Jul 12, 2023
6cd3fd8
Add valgrind to CI
jrchatruc Jul 12, 2023
ebec3c6
Install valgrind on CI
jrchatruc Jul 12, 2023
24cf32b
Run clean before valgrind target
jrchatruc Jul 12, 2023
b06b5f6
Add additional flags to valgrind in CI
jrchatruc Jul 12, 2023
b359a73
Add project guidelines to README
jrchatruc Jul 12, 2023
c6cb4d8
Add support for building C++ along C in the Makefile.
toni-calvin Jul 13, 2023
5040b41
Add support for building C++ along C in the Makefile.
toni-calvin Jul 13, 2023
490b87c
Add C++ json parser lib into project.
toni-calvin Jul 13, 2023
0c3c12b
WIP: Parsing json into program.
toni-calvin Jul 13, 2023
d19a485
WIP: Creating Program structure and parsing data
toni-calvin Jul 14, 2023
8a75a10
WIP : Extracting data
toni-calvin Jul 17, 2023
8bfd568
WIP: Printing stored data struct
toni-calvin Jul 17, 2023
c6b8e53
WIP: Freeing allocated memory for data struct
toni-calvin Jul 17, 2023
9143080
WIP: Testing data struct
toni-calvin Jul 17, 2023
e6a8b2a
WIP: Testing data struct
toni-calvin Jul 17, 2023
1ade0ca
Makefile changes and returning pointer
toni-calvin Jul 17, 2023
715e3a8
WIP: Parsing arrays and strings
toni-calvin Jul 17, 2023
a935e7e
Adding files to .gitignore
toni-calvin Jul 17, 2023
f2bcded
WIP: Testing data passed
toni-calvin Jul 18, 2023
5c334ee
WIP: Returning main value
toni-calvin Jul 18, 2023
9d789fa
WIP: Organizing and clearing testing
toni-calvin Jul 18, 2023
273be0b
Merge branch 'main' into json-parser-c
toni-calvin Jul 18, 2023
6d44965
Fixing imports
toni-calvin Jul 18, 2023
a00d3dc
Formatting files to satisfy fmt
toni-calvin Jul 18, 2023
8475a2e
Modifying Makefile to compile testing in c++
toni-calvin Jul 18, 2023
574b9a8
Adding lamdaworks library to Makefile
toni-calvin Jul 19, 2023
02be405
Fixing `div` conflict between stdlib and lamdaworks
toni-calvin Jul 19, 2023
ed41be7
Parsing json data array into program felts array
toni-calvin Jul 19, 2023
e54de80
Parsing testing
toni-calvin Jul 19, 2023
364620b
Working decoder tests
toni-calvin Jul 19, 2023
749677e
Restored deleted makefile prerequisite
toni-calvin Jul 19, 2023
bb869c6
"Added functionality for parsing attributes array"
toni-calvin Jul 20, 2023
7f92c86
"Added functionality for parsing compiler version"
toni-calvin Jul 20, 2023
da3e9aa
Add new line at end of la,bdaworks.h
toni-calvin Jul 21, 2023
f9bb054
Add new line at end of parser.h
toni-calvin Jul 21, 2023
fda7895
Parsing debug_info element
toni-calvin Jul 21, 2023
48b0d48
-Removing innecessary checks on test
toni-calvin Jul 21, 2023
13c5196
Fix makefile
jrchatruc Jul 24, 2023
9bb1d21
Parsing main_scope and prime fields
Jul 24, 2023
f116e7e
Formatting with clang properties
Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ dkms.conf

build/
.vscode/
.gdb_history
31 changes: 24 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ TARGET=cairo_vm
TEST_TARGET=cairo_vm_test

CC=cc
CXX=g++
SANITIZER_FLAGS=-fsanitize=address -fno-omit-frame-pointer
CFLAGS=-std=c11 -Wall -Wextra -Wimplicit-fallthrough -Werror -pedantic -g -O0
CXX_FLAGS=-std=c++14 -Wall -Wextra -Wimplicit-fallthrough -Werror -pedantic -g -O0
CFLAGS_TEST=-I./src

LN_FLAGS=-L./lambdaworks/lib/lambdaworks/target/release/ -llambdaworks

BUILD_DIR=./build
SRC_DIR=./src
TEST_DIR=./test
LIB_DIR=./lib

SOURCE = $(wildcard $(SRC_DIR)/*.c)
TEST_SOURCE = $(wildcard $(TEST_DIR)/*.c) $(wildcard $(SRC_DIR)/*.c)
TEST_SOURCE := $(filter-out %main.c, $(TEST_SOURCE))
SOURCE := $(filter-out %main.c, $(SOURCE))
SOURCE_CPP = $(wildcard $(SRC_DIR)/*.cpp)
LIB_SOURCE_CPP = $(wildcard $(LIB_DIR)/*.cpp)
TEST_SOURCE = $(wildcard $(TEST_DIR)/*.c)
TEST_SOURCE_CPP = $(wildcard $(TEST_DIR)/*.cpp) $(wildcard $(SRC_DIR)/*.cpp)

HEADERS = $(wildcard $(SRC_DIR)/*.h)
TEST_HEADERS = $(wildcard $(TEST_DIR)/*.h)
OBJECTS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SOURCE))
OBJECTS_CPP = $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SOURCE_CPP))
TEST_OBJECTS = $(patsubst $(TEST_DIR)/%.c, $(BUILD_DIR)/%.o, $(TEST_SOURCE))
LIB_OBJECTS_CPP = $(patsubst $(LIB_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(LIB_SOURCE_CPP))

# Gcc/Clang will create these .d files containing dependencies.
DEP = $(OBJECTS:%.o=%.d)
Expand All @@ -29,13 +38,13 @@ default: compile-rust $(TARGET)

$(TARGET): $(BUILD_DIR)/$(TARGET)

$(BUILD_DIR)/$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) $(SANITIZER_FLAGS) $(LN_FLAGS) $^ -o $@
$(BUILD_DIR)/$(TARGET): $(OBJECTS) $(OBJECTS_CPP) $(LIB_OBJECTS_CPP) $(SRC_DIR)/main.o
$(CXX) $(CXX_FLAGS) $(SANITIZER_FLAGS) $(LN_FLAGS) $^ -o $@

$(TEST_TARGET): $(BUILD_DIR)/$(TEST_TARGET)

$(BUILD_DIR)/$(TEST_TARGET): $(TEST_OBJECTS)
$(CC) $(CFLAGS) $(CFLAGS_TEST) $(SANITIZER_FLAGS) $(LN_FLAGS) $^ -o $@
$(BUILD_DIR)/$(TEST_TARGET): $(OBJECTS) $(OBJECTS_CPP) $(LIB_OBJECTS_CPP) $(TEST_OBJECTS)
$(CXX) $(CXX_FLAGS) $(SANITIZER_FLAGS) $(LN_FLAGS) $^ -o $@

-include $(DEP)

Expand All @@ -47,15 +56,23 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(SANITIZER_FLAGS) -MMD -c $< -o $@

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) $(SANITIZER_FLAGS) -MMD -c $< -o $@

$(BUILD_DIR)/%.o: $(TEST_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(CFLAGS_TEST) $(SANITIZER_FLAGS) -MMD -c $< -o $@

$(BUILD_DIR)/%.o: $(LIB_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) $(SANITIZER_FLAGS) -MMD -c $< -o $@

deps-macos:
brew install clang-format

run: default
$(BUILD_DIR)/$(TARGET)
$(BUILD_DIR)/$(TARGET)

test: compile-rust $(TEST_TARGET)
$(BUILD_DIR)/$(TEST_TARGET)
Expand Down
10 changes: 9 additions & 1 deletion lambdaworks/lib/lambdaworks.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
/* A single limb (unsigned integer with 64 bits). */
typedef uint64_t limb_t;

Expand All @@ -25,4 +29,8 @@ void sub(felt_t a, felt_t b, felt_t result);
void mul(felt_t a, felt_t b, felt_t result);

/* Writes the result variable with a / b. */
void div(felt_t a, felt_t b, felt_t result);
void lw_div(felt_t a, felt_t b, felt_t result);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion lambdaworks/lib/lambdaworks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ pub extern "C" fn mul(a: Limbs, b: Limbs, result: Limbs) {
}

#[no_mangle]
pub extern "C" fn div(a: Limbs, b: Limbs, result: Limbs) {
pub extern "C" fn lw_div(a: Limbs, b: Limbs, result: Limbs) {
felt_to_limbs(limbs_to_felt(a) / limbs_to_felt(b), result)
}
Loading