Skip to content

Commit

Permalink
Merge branch 'master' into Remove-bounds-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRT committed Jan 10, 2024
2 parents 2be4662 + 8afe308 commit 6894b75
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
name: Format

on: [push, pull_request]
#sdsdsd
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: julia-actions/julia-format@master
with:
args: -i 2 -v .
# Actions to be added here.
19 changes: 16 additions & 3 deletions src/dangerous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ function listSetRest(inConsCell::Cons{A}, inNewRest::Nil) where {A} #= A non-emp
local val = inConsCell.head
GC.@preserve unsafe_store!(lstPtr, Cons{A}(inConsCell.head, inNewRest))
return inConsCell
=======
function listReverseInPlace(inList::List{T}) where {T}
MetaModelica.listReverse(inList)
end

""" O(1). A destructive operation changing the \"first\" part of a cons-cell. """
function listSetFirst(inConsCell::Cons{A}, inNewContent::A) where {A} #= A non-empty list =#
@assign inConsCell.head = inNewConent
end

"""
O(1). A destructive operation changing the rest part of a cons-cell
NOTE: Make sure you do NOT create cycles as infinite lists are not handled well in the compiler.
"""
function listSetRest(inConsCell::Cons{T}, inNewRest::List{T}) where {T} #= A non-empty list =#
@assign inConsCell.tail = inNewRest
end


Expand Down Expand Up @@ -160,9 +176,6 @@ function unsafe_getListAsPtr(lst::List{T}) where {T}
end
end




"""
Unsafe function to get pointers from immutable struct.
Use with !care!
Expand Down
5 changes: 3 additions & 2 deletions src/matchcontinue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ function handle_destruct(value::Symbol, pattern, bound::Set{Symbol}, asserts::Ve
#= NONE is a function. However, we treat it a bit special=#
if $(esc(T)) !== NONE && typeof($(esc(T))) <: Function
func = $(esc(T))
throw(LoadError("Attempted to match on a function", @__LINE__,
file = @__FILE__
throw(LoadError("Attempted to match on a function at $(file)", @__LINE__,
AssertionError("Incorrect match usage attempted to match on: $func")))
end
if !(isstructtype(typeof($(esc(T)))) || issabstracttype(typeof($(esc(T)))))
throw(LoadError("Attempted to match on a pattern that is not a struct",
throw(LoadError("Attempted to match on a pattern that is not a struct at $(file)",
@__LINE__,
AssertionError("Incorrect match usage. Attempted to match on a pattern that is not a struct")))
end
Expand Down
12 changes: 6 additions & 6 deletions src/metaRuntime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ function stringDelimitList(strs::List, delimiter::String)::String
str
end

stringDelimitList(lst::Nil, delim::String) = "{}"

""" O(1) """
function stringLength(str::String)::ModelicaInteger
length(str)
Expand Down Expand Up @@ -504,7 +506,7 @@ function arrayEmpty(arr::Array{A})::Bool where {A}
end

""" O(1) """
function arrayGet(arr::Array{A}, index::ModelicaInteger)::A where {A}
function arrayGet(arr::Array{A}, index::ModelicaInteger) where {A}
if index < 0
println("arrayGet: index < 0!")
fail()
Expand All @@ -513,7 +515,7 @@ function arrayGet(arr::Array{A}, index::ModelicaInteger)::A where {A}
end

""" O(size) """
function arrayCreate(size::ModelicaInteger, initialValue::A)::Array{A} where {A}
function arrayCreate(size::ModelicaInteger, initialValue::A) where {A}
fill(initialValue, size)
end

Expand Down Expand Up @@ -763,7 +765,6 @@ The code generated from the transpiler is correct however"""
function isPresent(ident::T)::Bool where {T}
local b::Bool
b = true
b
end

#= The Info attribute provides location information for elements and classes. =#
Expand All @@ -779,7 +780,6 @@ end
end
end


SOURCEINFO(fileName::String, isReadOnly::Bool, lineNumberStart::ModelicaInteger,
columnNumberSTart::ModelicaInteger, lineNumberEnd::ModelicaInteger,
columnNumberEnd::ModelicaInteger) =
Expand Down Expand Up @@ -822,6 +822,6 @@ function StringFunction(r::Float64)::String
realString(r)
end

function String(a)::String
string(a)
function String(arg)::String
return string(arg)
end

0 comments on commit 6894b75

Please sign in to comment.