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

Implement :: operator #1550

Merged
merged 40 commits into from
Feb 27, 2024
Merged

Conversation

distributivgesetz
Copy link
Contributor

@distributivgesetz distributivgesetz commented Dec 12, 2023

Closes #854
Fixes #1414

Title says all.

I am still pretty new to this codebase, I'm learning as I'm going along so there's going to be a few mistakes. Please watch out for those, I will definitely get something wrong.

Features to implement:

  • Global shorthand
  • Static var disambiguation
  • Initial shorthand
  • type::variable and parent_type::variable initial shorthands
  • Proc reference

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@Hinaichigo
Copy link
Contributor

fqscD3

@Hinaichigo
Copy link
Contributor

Hinaichigo commented Jan 10, 2024

This fixes a lot of errors in fstation and /vg/, however I'm not sure everything is working as intended. if I pull this on top of master at 6ab4355:

Unless I am way off this seems to re-introduce some errors around the order of const variable initialization:

/obj/item/device/assembly
	name = "assembly"
	var/short_name //Short name of the assembly. If the name is "remote signalling device", short_name must be something like "signaler"

	desc = "A small electronic device that should never exist."
	icon = 'icons/obj/assemblies/new_assemblies.dmi'
	icon_state = ""
	flags = FPRINT
	siemens_coefficient = 1
	w_class = W_CLASS_SMALL
	starting_materials = list(MAT_IRON = 100)
	w_type = RECYK_ELECTRONIC
	throwforce = 2
	throw_speed = 3
	throw_range = 10
	origin_tech = Tc_MAGNETS + "=1"

	var/show_status = 1 //in order to prevent the signaler button in signaler.dm from saying "... is ready!" when examined
	var/secured = 1
	var/list/attached_overlays = list()
	var/obj/item/device/assembly_holder/holder = null
	var/cooldown = 0//To prevent spam
	var/datum/wires/connected = null
	var/wires = WIRE_RECEIVE | WIRE_PULSE

	var/const/WIRE_RECEIVE = 1			//Allows Pulsed(0) to call Activate()
	var/const/WIRE_PULSE = 2				//Allows Pulse(0) to act on the holder
	var/const/WIRE_PULSE_SPECIAL = 4		//Allows Pulse(0) to act on the holders special assembly
	var/const/WIRE_RADIO_RECEIVE = 8		//Allows Pulsed(1) to call Activate()
	var/const/WIRE_RADIO_PULSE = 16		//Allows Pulse(1) to send a radio message

	var/connection_text = "sending signals to" //For assembly frames

	var/list/accessible_values = list()

//<in another file:>

/obj/item/device/assembly/igniter
	name = "igniter"
	desc = "A small electronic device able to ignite combustable substances."
	icon_state = "igniter"
	starting_materials = list(MAT_IRON = 500, MAT_GLASS = 50)
	w_type = RECYK_ELECTRONIC
	origin_tech = Tc_MAGNETS + "=1"

	secured = 1
	wires = WIRE_RECEIVE

Errors:
Error OD0404 at code/modules/assembly/igniter.dm:10:9: var "wires" is not declared
Which seems related to #1011

Also:

/obj/item/weapon/implant/explosive/emp_act(severity)
	if(malfunction)
		return
	malfunction = IMPLANT_MALFUNCTION_TEMPORARY
	switch (severity)
		if(2.0)	//Weak EMP will make implant tear limbs off.
			if(prob(50))
				small_boom()
		if(1.0)	//Strong EMP will melt implant either making it go off, or disarming it
			if(prob(70))
				if(prob(50))
					small_boom()
				else
					if(prob(50))
						activate()		//50% chance of bye bye
74					else
						meltdown()		//50% chance of implant disarming
						return
	spawn(20)
		malfunction--

errors:
Error OD0019 at code/game/objects/items/weapons/implants/types/explosive_implant.dm:74:6: Label "label0" could not be resolved

@wixoaGit
Copy link
Member

wixoaGit commented Jan 11, 2024

Unless I am way off this seems to re-introduce some errors around the order of const variable initialization:

...

Errors: Error OD0404 at code/modules/assembly/igniter.dm:10:9: var "wires" is not declared Which seems related to #1011

This is because steps 5 and 6 were swapped around in DMObjectBuilder.BuildObjectTree(). Doing the steps in this order is incorrect, since now it tries to apply var overrides before all the vars have been defined. In this case wires hasn't been defined yet since the definitions for WIRE_RECEIVE and WIRE_PULSE come after.

@distributivgesetz distributivgesetz marked this pull request as draft January 11, 2024 18:04
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

# Conflicts:
#	DMCompiler/DM/DMExpression.cs
#	DMCompiler/DM/DMObject.cs
#	DMCompiler/DM/Expressions/Builtins.cs
#	DMCompiler/DM/Visitors/DMExpressionBuilder.cs
#	DMCompiler/DM/Visitors/DMObjectBuilder.cs
#	OpenDreamShared/Compiler/Token.cs
@Hinaichigo
Copy link
Contributor

What was the reason why those steps had to be reordered to get :: to work in this case?

@distributivgesetz
Copy link
Contributor Author

distributivgesetz commented Feb 6, 2024

What was the reason why those steps had to be reordered to get :: to work in this case?

Variable definitions as well as overrides have to be parsed in order for type:: and parent_type:: to evaluate to the correct values

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

# Conflicts:
#	DMCompiler/Compiler/DM/DMAST.cs
#	DMCompiler/Compiler/DM/DMParser.cs
#	DMCompiler/DM/Builders/DMExpressionBuilder.cs
#	DMCompiler/DM/Builders/DMObjectBuilder.cs
#	DMCompiler/DM/Expressions/Constant.cs
And other merge issues
@boring-cyborg boring-cyborg bot added the Compiler Involves the OpenDream compiler label Feb 12, 2024
@github-actions github-actions bot added size/XL and removed size/L labels Feb 27, 2024
@github-actions github-actions bot added size/XXL and removed size/XL labels Feb 27, 2024
@wixoaGit wixoaGit marked this pull request as ready for review February 27, 2024 03:56
@wixoaGit wixoaGit enabled auto-merge (squash) February 27, 2024 03:57
@wixoaGit wixoaGit merged commit 59e85ec into OpenDreamProject:master Feb 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler Involves the OpenDream compiler size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:: proc reference scope operator not being parsed correctly :: not implemented
3 participants